Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 2 select in one

Author  Topic 

jweizman
Starting Member

27 Posts

Posted - 2002-02-25 : 06:26:37
Hi

Assuming i have a table with one boolean Field

How could i have in one select the number of False and number of true ?

Jonathan

Nazim
A custom title

1408 Posts

Posted - 2002-02-25 : 07:29:39

select count(case columnname when true then 1 else null end) NoOfTrue,count(case columnname when false then 1 else null end) NoOfFalse
from tablename

Check for Case in BOL.

HTH

--------------------------------------------------------------
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-02-25 : 07:42:58
select convert(int,bitfield), count(bitfield)
from repository
group by convert(int,bitfield)



should work.

Go to Top of Page
   

- Advertisement -