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 modif
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
The easiest thing to do would be to create an additional table
containing all the possible valid values for contract level, then join
on that table to show counts. 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
Thank you, Peng Yi-fan
but incase there is no contract with the level 5, it will not be shown.
I would like to see:
level amount
1 34
2 0
3 18
4 986
5 0
I could add it in the application, but I try to do it within the Query.
btw. the right join I mentioned, doesn
The schema of your contract should be like this:
Contract (id, level, ...)
where column 'id' is the primary key, isn't it?
If so, you can try this:
SELECT COUNT(id)
FROM contract
GROUP BY level
- Original Message -
From: "Jay" <[EMAIL PROTECTED]>
To:
Sent: Thursday, May 11, 2006 5:4