I am running PostgreSQL. I have a table called foo.Its content are:
city|number
'oo'|12
'ss'|11
'ss'|23
'oo'|11
'pp'|21
If I run a query like select count(city) from foo group by city having number<21 I will get
city|number
'oo'|2
'ss'|2
but I want the result to consider all the possible cases of city like this:
city|number
'oo'|2
'ss'|2
'pp'|0
How should the query look like?
<21, which is whyppwon't show up.HAVING number <= 21?'ss'|1?? Not to mention there is no ID in your table!