MySql group and filter results : error -
i need : query works
select count(distinct(a.mat)),count(distinct(c.mail)) nb aca left join c on c.mat=a.mat group a.mat order nb desc;
but when want filter
select count(distinct(a.mat)),count(distinct(c.mail)) nb aca left join c on c.mat=a.mat group a.mat order nb desc nb > 0;
i error
error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near 'where nb>0' @ line 6
what's wrong in query ?
conditions on grouped function should put having clause:
select count(distinct(a.mat)),count(distinct(c.mail)) nb aca left join c on c.mat=a.mat group a.mat having nb > 0 order nb desc;
Comments
Post a Comment