我想用出现次数选择不同的键,此查询似乎起作用:
SELECT ItemMetaData.KEY, ItemMetaData.VALUE, count(*) FROM ItemMetaData GROUP BY ItemMetaData.KEY ORDER BY count(*) desc;
但是我也想过滤这些结果,这意味着我只想在count(*)大于2500的情况下,才显示大于2500的发生率,但是:
SELECT * FROM ( SELECT ItemMetaData.KEY, ItemMetaData.VALUE, count(*) FROM ItemMetaData GROUP BY ItemMetaData.KEY ORDER BY count(*) desc ) as result WHERE count(*)>2500;
不幸的是,该查询导致语法错误。你能帮我达到我的要求吗?
聚合的HAVING子句
SELECT ItemMetaData.KEY, ItemMetaData.VALUE, count(*) FROM ItemMetaData Group By ItemMetaData.KEY, ItemMetaData.VALUE HAVING count(*) > 2500 ORDER BY count(*) desc;