I've got this table named log:
ID User_ID Machine_Number Email 1 100 12345 [email protected] 2 100 12345 [email protected] 3 101 67890 [email protected] 4 102 12345 [email protected] I need to find the User_IDs of users with the same Machine_Number. In this case, I need a query that returns 100 and 102.
I've tried:
SELECT user_id, COUNT(machine_number) FROM log GROUP BY machine_number HAVING COUNT(machine_number) > 1 but that gives the count of each occurrence of the machine_number, i.e. User_ID Count(machine_number)
100 2 101 1 102 1 Any suggestions?