Chapter 4. GROUP BY
Because GROUP BY can involve a sort , much of what we said about ORDER BY columns in the previous chapter applies for GROUP BY arguments tookeep 'em short and keep few of 'em. Beyond that, you should watch out for some other things when you write a grouping query. In this chapter, we'll look at optimizing GROUP BY and its related HAVING clause, as well as the SQL Standard set functions.