tags:

views:

36

answers:

1

Okay so I have a database field called moderated

It is an ENUM with 3 values:

approved
denied
unmoderated

How can I write a query that counts the amount of each, so I can generate this output:

Approved: 3
Denied: 10
Unmoderated: 23
+4  A: 

If I understood your question correctly, you can write like this:

Select Moderated, Count(Moderated)  FROM YourTable
Group BY Moderated

If you want output in "approved: 3" format, you can add "Convert(Varchar(10), Moderated) + ':' + Convert(Varchar(10), Count(Moderated))" to you column list in you select statement.

24x7Programmer
ty very much sire!
Joshua