Reputation: 44051
For example suppose I have the following table
user_id, score
1,5
1,4
2,9
3,7
3,6
3,15
4,8
4,11
I want a query that returns user_id 2 because it is the only user_id that is not repeated
Upvotes: 2
Views: 445
Reputation: 454980
select user_id
from tableName
group by user_id
having count(*) = 1;
Upvotes: 1
Reputation: 20234
SELECT user_id FROM table GROUP BY(user_id) HAVING COUNT(user_id) = 1
Upvotes: 7