Movatterモバイル変換


[0]ホーム

URL:


Categories:

Query syntax

HAVING

Filters rows produced byGROUP BY that do not satisfy a predicate.

Syntax

SELECT...FROM...GROUPBY...HAVING<predicate>[...]
Copy

Parameters

predicate

ABoolean expression.

Usage notes

  • The condition specified by the HAVING clause applies to expressions produced by theGROUP BY.Therefore, the same restrictions that apply toGROUP BY expressions also apply to the HAVINGclause. The predicate can only refer to:

  • Expressions in theSELECT list can be referred to by the column alias defined in the list.

Examples

Find the departments that have fewer than 10 employees:

SELECTdepartment_idFROMemployeesGROUPBYdepartment_idHAVINGcount(*)<10;
Copy
Language:English

[8]ページ先頭

©2009-2025 Movatter.jp