sql: display result when condition count(ill)<=5 -
i want generate report special illness report condition number of count of illness more or equal 5.the sql query cannot run :
select a.treatid ,b.patid ,b.patname ,b.tel ,a.ill ,count(a.ill) treatment a, patient a.patid=b.patid , count(ill)<=5; the query did not generate result expected. generate treatment count(ill) =1 .
anyone can me solve problem.
i tired in testing query.
because have count(a.ill) in select statement - need use having clause in conjunction group by. example:
select b.patid, b.patname, b.tel, a.ill, count(a.ill) treatment inner join patient b on a.patid=b.patid group a.ill, b.patid, b.patname, b.tel having count(a.ill)<=5;
Comments
Post a Comment