Last active
December 5, 2019 13:11
-
-
Save jervalles/bee5913aa67dfc7183d7916bf8ff0be7 to your computer and use it in GitHub Desktop.
06 - SQL Avancé
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select team.name, COUNT(*) AS nb_wizard | |
from (wizard | |
JOIN player ON (player.wizard_id=wizard.id) | |
JOIN team ON (player.team_id=team.id)) | |
GROUP BY team.id | |
ORDER BY nb_wizard DESC; | |
'Gryffindor', '36' | |
'Slytherin', '21' | |
'Ravenclaw', '15' | |
'Hufflepuff', '12' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select team.name, COUNT(*) AS nb_wizard | |
from (wizard | |
JOIN player ON (player.wizard_id=wizard.id) | |
JOIN team ON (player.team_id=team.id)) | |
GROUP BY team.id | |
HAVING nb_wizard >= 14 | |
ORDER BY name ASC; | |
'Gryffindor', '36' | |
'Ravenclaw', '15' | |
'Slytherin', '21' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select firstname, lastname, name Team_Name | |
from (wizard | |
JOIN player ON (player.wizard_id=wizard.id) | |
JOIN team ON (player.team_id=team.id)) | |
WHERE DAYOFWEEK(enrollment_date) = 2 | |
AND name = 'Gryffindor'; | |
'Sirius', 'Black', 'Gryffindor' | |
'Aberforth', 'Dumbledore', 'Gryffindor' | |
'Godric', 'Gryffindor', 'Gryffindor' | |
'Alice', 'Longbottom', 'Gryffindor' | |
'Augusta', 'Longbottom', 'Gryffindor' | |
'George', 'Weasley', 'Gryffindor' | |
'Cadogan', '', 'Gryffindor' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment