How to count two fields by using Select statement in SQL Server 2005?
Posted
by user144842
on Stack Overflow
See other posts from Stack Overflow
or by user144842
Published on 2010-05-12T14:17:37Z
Indexed on
2010/05/12
14:24 UTC
Read the original article
Hit count: 174
Total records in table are 10.
Select count(ID) from table1 where col1 = 1 (Result is 8)
Select count(ID) from table1 where col2 = 1 (Result is 2)
So its a same table but count is based on different condition. How am i gonna get two results (counts) using one select statement?
Also Performance is a big concern here.
PS: I am using Stored procedure...
© Stack Overflow or respective owner