Reputation: 3
I can't correctly write a query. I need to select a person who has only one value in the column. For example,
select * (
select PersonID, sum(TotalAmount)
from Table1
group by PersonID
HAVING sum(TotalAmount) = 0 )
where Group = A
It means that I would select all customers that belong to ONLY 'A' group...
Could someone help me?
Upvotes: 0
Views: 995
Reputation: 1269443
If you want the persons with only one value, then having count(*) = 1
comes to mind:
select personid
from table1
group by personid
having count(*) = 1;
Upvotes: 1