Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT people1.ID, people1.name
- FROM People people1,
- GROUP BY people1.ID -- Can probably skip this?
- HAVING 0 < COUNT(--For each person, counts how many times they did not have the worst score for each sport
- SELECT *
- FROM
- (SELECT results1.sportID, MAX(results1.RESULT)
- FROM Results results1,
- WHERE results.peopleID == people1.ID
- GROUP BY results1.sportID) AS personBest, -- For each person, creates a table with his best score for each sport
- (SELECT results1.sportID, MIN(results1.RESULT)
- FROM Results results1
- WHERE results1.sportID IN
- (SELECT UNIQUE results.sportID
- FROM Results results
- WHERE results.peopleID == people1.ID)
- GROUP BY results1.sportID) AS sportWorst -- For each person, creates a table with the worst score for each sport the person played in
- WHERE sportWorst.sportID = personBest.sportID AND sportWorst.RESULT != personBest.RESULT
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement