sqlite(17)-Having子句

Having子句允许指定条件来过滤将出现在最终结果的分组结果。
WHERE子句在所选列上设置条件,而Having子句则在由Group By子句创建的分组这是条件。

语法#

SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY


SELECT column1, column2
FROM table1, table2
WHERE [conditions]
GROUP BY column1, column2
HAVING [conditions]
ORDER BY column1, column2

实例#

sqlite(17)-Having子句_第1张图片
样例表

SELECT * FROM COMPANY GROUP BY name HAVING count(name) < 2;

你可能感兴趣的:(sqlite(17)-Having子句)