Skip to content

Instantly share code, notes, and snippets.

@GuillaumeLoup
Created May 28, 2019 09:13
Show Gist options
  • Save GuillaumeLoup/2d9aca8e5865b1e8e4eb9e2411a99520 to your computer and use it in GitHub Desktop.
Save GuillaumeLoup/2d9aca8e5865b1e8e4eb9e2411a99520 to your computer and use it in GitHub Desktop.
quete sql avancé
SELECT team.name, COUNT(wizard_id) AS nb_players
FROM player
JOIN team ON team.id=player.team_id
JOIN wizard ON wizard.id=player.wizard_id
GROUP BY team.name
ORDER BY nb_players DESC;
SELECT team.name
FROM team
JOIN player ON team.id=player.team_id
GROUP BY team.name
HAVING COUNT(player.id) >= 14
ORDER BY COUNT(player.id) DESC;
SELECT CONCAT(lastname, " ", firstname) AS lundi_player FROM wizard
JOIN player ON wizard.id=player.wizard_id
JOIN team ON team.id=player.team_id
WHERE dayofweek(enrollment_date)=2 AND team.name="Gryffindor"
ORDER BY player.enrollment_date;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment