sql - Show null counts with a condition of <= 2 -
currently trying find diagnosed diseases have been diagnosed between 0-2 times. able show how many times each disease has been diagnosed, including 0, try view ones have count of 0-2, query doesn't work.
this gets me counts (including 0):
select disease.name, count(diagnosed.diseaseid) timesdiagnosed disease left join diagnosed on disease.diseaseid = diagnosed.diseaseid group disease.name; and code doesn't work :
select disease.name, count(diagnosed.diseaseid) timesdiagnosed disease left join diagnosed on disease.diseaseid = diagnosed.diseaseid group disease.name order disease.name having count(diagnosed.diseaseid) <= 2; my rdmbs oracle.
having clause should go before order by , after group by:
select disease.name, count(diagnosed.diseaseid) timesdiagnosed disease left join diagnosed on disease.diseaseid = diagnosed.diseaseid group disease.name having count(diagnosed.diseaseid) <= 2 order disease.name
Comments
Post a Comment