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 |
DaveBF
Yak Posting Veteran
89 Posts |
Posted - 2012-11-29 : 07:27:15
|
How do I Select the number of records where a certain column is equal to a certain value?Select Count(where Rating = 5) from Awards as NumberOf5RatingsThanks! |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-11-29 : 07:30:15
|
SELECT SUM(CASE WHEN Rating = 5 THEN 1 ELSE 0 END) as NumberOf5RatingsFROM Awardsor justSELECT COUNT(*) as NumberOf5RatingsFROM yourTableWHERE Rating = 5JimEveryday I learn something that somebody else already knew |
|
|
DaveBF
Yak Posting Veteran
89 Posts |
Posted - 2012-11-29 : 07:32:08
|
Thank you. |
|
|
|
|
|