我想使用第二列(art_count)仅显示那些包含总art_count的X%的行。
我的资料:
title art_count a 3 b 12 c 9 d 4 e 45
到目前为止我的查询:
SELECT title, COUNT(art) AS art_count FROM table1 GROUP BY art HAVING ... ?
使用SUM进行了尝试,但未成功。
SELECT title, COUNT(art) AS art_count FROM table1 GROUP BY art HAVING art_count >= (select count(*) * X / 100 from table1)
您需要为插入一个值 X
X