HAVING and WHERE are often confused by beginners, but they serve different purposes. WHERE is taken into account at an earlier stage of a query execution, filtering the rows read from the tables. If a query contains GROUP BY, data from the tables are grouped and aggregated. After the aggregating operation, HAVING is applied, filtering out the rows that don't match the specified conditions. Therefore, WHERE applies to data read from tables, and HAVING should only apply to aggregated data, which are not known in the initial stage of a query.
To view the present condition formed by the GROUP BY clause, the HAVING clause is used.
关于·帮助文档·FAQ·API·我们的愿景·广告投放·感谢·实用小工具· 2082 人在线最高记录 5497· Select Language
World is powered by solitude
VERSION: 18.104.22.168 · 52ms · UTC 09:12 · PVG 17:12 · LAX 02:12 · JFK 05:12 ♥ Do have faith in what you're doing.