I have table like that:
user_id | points
--------+--------
1 10
1 500
2 2
2 6
3 5
3 50
Now I want to calculate how many users has SUM(points) between, for example, between 1 and 80, betwee 81 and 140, etc. How can I get it? In SQL it looks like it can be done only vie embedded SQL query - internal for grouping with HAVING clause and external - for counting rows in resultset.