sql - Why does the HAVING clause need to come after the GROUP-BY? -
i want understand logically why need having clause after group-by ?
select name actor id in ( select actorid casting ord = 1 group actorid having count(*) > 29 ) order name asc
it hasn't clicked yet me, why following incorrect :
having count(*) > 29 group actorid
the reason because sql group records before evaluates having clause.
it sql syntax, makes intuitive sense, jeroen points out :
having applies result of grouping, in particular, unusual case, sql following chronological order of query steps.
Comments
Post a Comment