Quantcast
Viewing latest article 21
Browse Latest Browse All 62

Need to get common users for every combination of user IDs - response (1) by dnoeth

SELECT t1.UserId, t2.UserId, COUNT(*)
FROM tab AS t1 
JOIN tab AS t2
  ON t1.UserId < t2.UserId   -- different user id 
 AND t1.UserId1 = t2.UserId1 -- same user id 1
GROUP BY 1,2 

 


Viewing latest article 21
Browse Latest Browse All 62

Trending Articles