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
 General SQL Server Forums
 New to SQL Server Programming
 Combining Columns

Author  Topic 

cutiebo2t
Constraint Violating Yak Guru

256 Posts

Posted - 2010-04-22 : 22:33:22
Hi,

I have this table:

Name Priority
Roel Aging
Roel Within 24
Noel Within 24
Roel Aging
Noel Aging
Roel Aging

What I want is to count Priority showing this results:

Name Aging Withing 24
Roel 3 1
Noel 1 1

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-22 : 22:35:15
are you using SQL Server 2005 / 2008 ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

cutiebo2t
Constraint Violating Yak Guru

256 Posts

Posted - 2010-04-22 : 22:36:14
2000 Sir
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-22 : 22:38:50
[code]
select [Name],
count(case when Priority = 'Aging' then Priority end) as [Aging],
count(case when Priority = 'Within 24' then Priority end) as [Within 24]
from yourtable
group by [Name]
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

cutiebo2t
Constraint Violating Yak Guru

256 Posts

Posted - 2010-04-22 : 22:41:03
got it thanks. that was helpful.
Go to Top of Page
   

- Advertisement -