Eine Einführung in

SQL

SQL0120N A WHERE clause, GROUP BY clause, SET clause, or SET transition-variable statement contains a column function.

DB2

Problem

We want to filter the results returned based on an aggregate function such as COUNT or SUM.

The WHERE clause may not be used for this. The WHERE conditions are considered before the aggregation.

Solutions

  • Put the condition into the HAVING clause, after the GROUP BY clause.
  • SELECT winner FROM nobel
      GROUP BY winner
      HAVING COUNT(winner)>1


Specific to DB2
none