Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

can we use count function twice in one query.
i am using sql server 2005.

I want count of
>users who completed courses and
>users who are pending.

Query is with join so is it affect count function?
Posted

SQL
declare @Count table (id int,Status varchar(2))
insert into @Count
values(1,'C'),(2,'C'),(3,'P'),(4,'C'),(5,'P'),(6,'P'),(7,'C')

select * from
(select count(Status)'Pending' from @Count where Status='P')T,
(select count(Status)'Completed' from @Count where Status='C')V
 
Share this answer
 
 
Share this answer
 
Comments
Sweetynewb 7-Mar-13 5:59am    
I think this solution will help me out. but i want group by(course) clause too.
RedDk 7-Mar-13 12:20pm    
So click-on his link then use the "find-on-page" feature of your browser using the word "group", yes?
Sampath Sridhar 8-Mar-13 1:26am    
Sorry, my mistake.
Thanks for the update OriginalGriff :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900