Reputation: 2551
I am using this query to filter some record from my sql database:
select Distinct x, SUM(y)AS Total
from T
where j=2
group by x
The returned values are as follows:
2585 -1
1804 -8
1781 900.56
1712 -6
1612 -2
2591 66
Is there a way to filter the result where Sum(y) > 0
?
Upvotes: 0
Views: 33
Reputation: 28930
Use Having.Where clause acts on individual records,Having acts on Groups
select Distinct x,
SUM(y)AS Total from T
where j=2 group by x
having sum(y)>0
Upvotes: 2