Skip to content

Instantly share code, notes, and snippets.

@Morzanne
Created June 4, 2019 15:23
Show Gist options
  • Save Morzanne/f8701c681745e979d1c3f3e1ded40a9b to your computer and use it in GitHub Desktop.
Save Morzanne/f8701c681745e979d1c3f3e1ded40a9b to your computer and use it in GitHub Desktop.
SELECT team.name, COUNT(wizard.id) AS total FROM player
JOIN wizard ON player.wizard_id = wizard.id
JOIN team ON player.team_id=team.id
GROUP BY team.name
ORDER BY COUNT(wizard.id) DESC;
SELECT team.name FROM player
JOIN team ON player.team_id=team.id
GROUP BY team.name
HAVING COUNT(player.wizard_id)>=14;
SELECT wizard.firstname FROM player
JOIN wizard ON player.wizard_id=wizard.id
JOIN team ON player.team_id=team.id
WHERE DATE_FORMAT(player.enrollment_date, "%a")="Mon"
AND team.name="Gryffindor"
ORDER BY player.enrollment_date ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment