Guest User

Untitled

a guest
Jan 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. id team week
  2. 1 1 1
  3. 1 2 1
  4. 2 2 1
  5. 2 1 2
  6.  
  7. SELECT
  8. t1.id,
  9. t1.week
  10. FROM
  11. YourTable t1
  12. JOIN YourTable t2
  13. ON t1.ID = t2.ID
  14. AND t1.team < t2.team
  15. AND t1.week = t2.week
  16.  
  17. SELECT id
  18. FROM YourTable
  19. GROUP BY id
  20. HAVING COUNT(DISTINCT week) = 1 AND COUNT(DISTINCT team) <> 1
  21.  
  22. SELECT distinct id
  23. FROM TeamWeek
  24. GROUP BY id, week
  25. HAVING Count(team) > 1
  26.  
  27. SELECT ID
  28. , COUNT(DISTINCT TEAM) AS CNT_TEAM
  29. , COUNT(DISTINCT WEEK) AS CNT_WEEK
  30. FROM TABLENAME
  31. GROUP BY ID
  32. HAVING COUNT(DISTINCT TEAM) > 1
  33. AND COUNT(DISTINCT WEEK) = 1
Add Comment
Please, Sign In to add comment