GROUP BY Clause for Oracle PL/SQL

GROUP BY Clause Oracle PL/SQL

Normal GROUP BY

A few things to remember about the GROUP BY clause for Oracle.

  1. Any fields not part of an aggregate function (i.e. MAX() , SUM()  ) in the SELECT clause must be listed in the GROUP BY  clause.
  2. Limiting data returned for any aggregate function must be listed in the HAVING clause and not the WHERE clause.

With Hints

You must use the hint in the GROUP BY function exactly the same as the non-aggregate function

With CASE Statement

Example of GROUP BY with the CASE statement