May 16, 2005 at 7:29 am
I need three columns:
Dept
No of Users with XP
No of Users per Department (where Users have been given XP)
Users per Departments and No of Users with XP are both from the same column
Format required
Dept Users per Departments No of Users with XP
sales 40 2
but the client is from the same column so I keep getting
sales 2 2
I get 40 in both if I use a self join, but when I state code = 'XP' I get 2 in both. How do I query against the same table and get 2 answers
Thanks
May 16, 2005 at 7:33 am
Select Dept, count(*) as UserPerDepartement, sum(case when Col = 'XP' THEN 1 ELSE 0 END) from dbo.YourTable group by Dept
May 16, 2005 at 8:17 am
I have 2 queries.
select dept,count(user)
from dept
select dept, count(user)
from dept
where code = 'XP'
tried combining -
select dept,count(d.user),count(e.user)
from dept d, dept e
where code = 'XP'
but I get the same results in d.user and e.user.. I need 2 different result sets from the same column
Dept No in Departments No of Users with XP
sales 40 2
Finance 60 10
marketing 10 2
but the client is from the same column so I keep getting
sales 40 40
Finance 60 60
marketing 10 10
and
sales 12 12
Finance 10 10
marketing 12 12
May 16, 2005 at 8:20 am
What do you get from my query?
May 18, 2005 at 10:33 am
Thanks remi, works a treat
May 18, 2005 at 12:00 pm
HTH.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply