encyclopegia.org

Having (SQL)

A HAVING clause in SQL specifies that an SQL SELECT statement must only return rows where aggregate values meet the specified conditions.

A HAVING clause in SQL specifies that an SQL SELECT statement must only return rows where aggregate values meet the specified conditions. SELECT DeptID, SUM(SaleAmount) FROM Sales WHERE SaleDate = '2000-01-01' GROUP BY DeptID HAVING SUM(SaleAmount) > 1000 Referring to the sample tables in the Join example, the following query will return the list of departments which have more than 1 employee: SELECT DepartmentName, COUNT(*) FROM Employee JOIN Department ON Employee.DepartmentID = Department.DepartmentID GROUP BY DepartmentName HAVING COUNT(*) > 1; HAVING is convenient, but not necessary. Code equivalent to the example above, but without using HAVING , might look like: SELECT * FROM ( SELECT DepartmentName AS deptNam, COUNT(*) AS empCount FROM Employee AS emp JOIN Department AS dept ON emp.DepartmentID = dept.DepartmentID GROUP BY deptNam ) AS grp WHERE grp.empCount > 1; ==External links== The HAVING and GROUP BY SQL clauses SQL Aggregate Functions

References

No reference rows published for this article.

Cite this article

MLA

"Having (SQL)." encyclopegia.org, 2025, https://encyclopegia.org/wiki/having-sql. Accessed 24 November 2026.

Chicago

"Having (SQL)." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/having-sql.

APA

encyclopegia.org. (2025). Having (SQL). Retrieved November 24, 2026, from https://encyclopegia.org/wiki/having-sql

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Rose Meth

enwiki · references available

Antrim, Nova Scotia

enwiki · references available

Stand (Michael W. Smith album)

enwiki · references available

Irish Medical Times

enwiki · references available

Rose Tapley

enwiki · references available

Sobornost

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1328745217 · 0.5 · snapshot enwiki-001328745217

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.