On Thursday 17 Jul 2003 1:05 am, Rick Measham wrote: > I know this is tangential to this list's purpose, but I figure > someone here can help me out with some SQL. > > I have a table with a 'status' column. What I need it a count of each > status so that my result would be: > > count | status > -------------- > 213 | 1 > 90 | 3 > 122 | 2 > > Where the sql would be something like: > SELECT count(status), status FROM table WHERE condition > > Thanks for your help and for your forgiveness for an OT question. > > Cheers! > Rick
Hi Rick, you've not said which SQL server you're using, but I don't think that this should matter for this select. Try Select count(status), status from table group by status; It's the group by that splits up the count() into usefull data. Obviously you would stick in whatever where clause you want. (If it's PostgreSQL that you're using, you could do much worse than subscribe to [EMAIL PROTECTED] All the lists are accessible from http://www.postgresql.org/lists.html ) Gary -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
