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

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -