Reputation: 35
I want to use the second column (art_count) to show only those rows containing X percent of total art_count.
My data:
title art_count
a 3
b 12
c 9
d 4
e 45
My query so far:
SELECT title, COUNT(art) AS art_count
FROM table1
GROUP BY art HAVING ... ?
Tried it with SUM without success.
Upvotes: 3
Views: 3058
Reputation: 204746
SELECT title, COUNT(art) AS art_count
FROM table1
GROUP BY art
HAVING art_count >= (select count(*) * X / 100 from table1)
You need to insert a value for X
Upvotes: 6