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.
| Author |
Topic |
|
SuperSQLNewb
Starting Member
9 Posts |
Posted - 2009-04-23 : 11:58:33
|
| Hi guys,I have a table like this:ID Status1 New2 Old3 Can4 New5 New6 OldAnd I want the output of my query to be like this:Status CountNew 3Old 2Can 1I just want to display all of the various status values in the table and a count for how many each one has.How can I do this? I assume I need to use DISTINCT, COUNT and GROUP BY somehow but I can't seem to make it work.Thanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-04-23 : 12:01:16
|
select Status, Count(*) as [Count] from table group by Status No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
SuperSQLNewb
Starting Member
9 Posts |
Posted - 2009-04-23 : 12:10:57
|
| Thanks! You Yak'n'Roll |
 |
|
|
|
|
|