SELECT Query GROUP BY

2006-05-11 Thread Jay
Hello MySQL Users I have a contract table. Each contract has a certain level, which can be in a range from 1-5. This information is stored as a number. There is no additional table for the levels. I would like to get a list with the amount of contracts of each level - including 0 for the levels

Re: SELECT Query GROUP BY

2006-05-11 Thread Peng Yi-fan
, May 11, 2006 5:41 PM Subject: SELECT Query GROUP BY Hello MySQL Users I have a contract table. Each contract has a certain level, which can be in a range from 1-5. This information is stored as a number. There is no additional table for the levels. I would like to get a list

Re: SELECT Query GROUP BY

2006-05-11 Thread Jay
- From: Jay [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Thursday, May 11, 2006 5:41 PM Subject: SELECT Query GROUP BY Hello MySQL Users I have a contract table. Each contract has a certain level, which can be in a range from 1-5. This information is stored as a number

Re: SELECT Query GROUP BY

2006-05-11 Thread Dan Buettner
COUNT(id) FROM contract GROUP BY level - Original Message - From: Jay [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Thursday, May 11, 2006 5:41 PM Subject: SELECT Query GROUP BY Hello MySQL Users I have a contract table. Each contract has a certain level, which can be in a range

Re: SELECT Query GROUP BY

2006-05-11 Thread Jay
Thank you Dan, [...] Otherwise it's just not possible to show what's not there - in your case, think of this: how would MySQL know to show 5 when there are no 5's, but not also show the count for every other integer that's not there? (6, 7, 8, .. 1048576, 1048577, etc.) [...] Sure, easy to

Re: SELECT Query GROUP BY

2006-05-11 Thread Dan Buettner
No problem, glad to help. I noticed your comment in an earlier message about it seeming like a workaround - I don't think it seems like a workaround at all. Having a table with the possible values makes for a normal database structure, and an approach that should keep you from having to