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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -