I've made a post here a link , asking some question about how to make statistics for number of users with from same age group so i can show pie chart. I want to take query in older post to higher level with percentages along with values...
Means i to have count(userID) of certain age group / count(userID) of all * 100 to get percentage. While i want to get results with 10% or more all others should be listed as others with their total percentage.
This initial query made by Martin Smith
With Ages As
(
select count(userID) ageCount,userBirthYear
from Users
group by userBirthYear
)
SELECT ageCount,userBirthYear FROM Ages WHERE ageCount>5
UNION ALL
SELECT sum(ageCount) ,'others' As userBirthYear FROM Ages WHERE ageCount<=5
thanks