Currently trying to find diagnosed diseases that have been diagnosed between 0-2 times. i am able to show how many times each disease has been diagnosed, including 0, but as soon as i try to view the ones that have a count of 0-2, my query doesn't work.
this gets me the counts (including 0):
select disease.name, count(diagnosed.diseaseid) as timesdiagnosed
from disease
left join diagnosed on disease.diseaseid = diagnosed.diseaseid
group by disease.name;
and this code doesn't work :
select disease.name, count(diagnosed.diseaseid) as timesdiagnosed
from disease
left join diagnosed on disease.diseaseid = diagnosed.diseaseid
group by disease.name
order by disease.name
having count(diagnosed.diseaseid) <= 2;
My RDMBS is oracle.
答案 0 :(得分:2)
true
子句应该在test:start()
之前和having
之后:
order by