Re: Count Columns Where True
Try something like this:SELECT b.BizID, SUM(CASE WHEN t2.Col1 = 'false' then 1 else 0 end + CASE WHEN t2.Col2 = 'false' then 1 else 0 end + CASE WHEN t2.Col3 = 'false' then 1 else 0 end) as QtyT2 FROM...
View ArticleRe: Count Columns Where True
Thanks for your reply! I think I am getting really close.However, your query is counting each unique BizID record as '1'. What I need is to count as '1' each Col1, Col2, Col3 that = 'false'.So for...
View ArticleRe: Count Columns Where True
You should include your table DDL and some sample data and expected result to get better help.
View ArticleRe: Count Columns Where True
Hi,Try something like this:SELECT b.BizID, COUNT(t2.BizID) as QtyT2 FROM BizID as b LEFT JOIN Table2 as t2 on t2.BizID = b.BizID and t2.Col1 = 'false' and t2.Col2 = 'false' and t2.Col3 = 'false' WHERE...
View ArticleRe: Count Columns Where True
It doesn't seem to like this at all:Dim connstr As String = ConfigurationManager.ConnectionStrings("MyString").ToString() Dim ss As New SqlConnection(connstr) Dim sqlStr As String = "SELECT BizID FROM...
View ArticleRe: Count Columns Where True
Thanks for your reply.So would I do my SQL query like this?SELECT COUNT (SELECT Col1 WHERE Col1 = 'false', Col2 WHERE Col2 = 'false', Col3 WHERE Col3 = 'false') WHERE BizID = @BizID
View ArticleRe: Count Columns Where True
Oh don't try to do that in .net unless you like Excedrin Migraine. Do that in T-SQL.You simply need to group by all columns you want to count then sum them.Here's some pseudo:Select COUNT(Col1) +...
View ArticleCount Columns Where True
Hi,I have two tables. Table1 contains distinct business customers and selects all the businesses that are associated with each salesman. Then, I add that data to a dt1. Next, I need to loop through...
View Article
More Pages to Explore .....