Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id team week
- 1 1 1
- 1 2 1
- 2 2 1
- 2 1 2
- SELECT
- t1.id,
- t1.week
- FROM
- YourTable t1
- JOIN YourTable t2
- ON t1.ID = t2.ID
- AND t1.team < t2.team
- AND t1.week = t2.week
- SELECT id
- FROM YourTable
- GROUP BY id
- HAVING COUNT(DISTINCT week) = 1 AND COUNT(DISTINCT team) <> 1
- SELECT distinct id
- FROM TeamWeek
- GROUP BY id, week
- HAVING Count(team) > 1
- SELECT ID
- , COUNT(DISTINCT TEAM) AS CNT_TEAM
- , COUNT(DISTINCT WEEK) AS CNT_WEEK
- FROM TABLENAME
- GROUP BY ID
- HAVING COUNT(DISTINCT TEAM) > 1
- AND COUNT(DISTINCT WEEK) = 1
Add Comment
Please, Sign In to add comment