Reputation: 11
TYPE VALUE
A 4
A 5
A 6
B 1
B 1
I need to check which type has sum(value) < 3, but i can't find a way to return sum(value) of a specific type for the comparison operator.
Upvotes: 1
Views: 38
Reputation: 311338
Just group by the type and apply a having
clause:
SELECT type
FROM mytbale
GROUP BY type
HAVING SUM(value) < 3
Upvotes: 3