Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Database changed
- SELECT team.name, COUNT(wizard.firstname)
- AS nbplayer FROM player
- INNER JOIN wizard ON wizard.id = player.wizard_id
- INNER JOIN team ON team.id = player.team_id
- GROUP BY team.name ORDER BY nbplayer DESC;
- +------------+----------+
- | name | nbplayer |
- +------------+----------+
- | Gryffindor | 36 |
- | Slytherin | 21 |
- | Ravenclaw | 15 |
- | Hufflepuff | 12 |
- +------------+----------+
- 4 rows in set (0.00 sec)
- SELECT team.name FROM player
- INNER JOIN wizard ON wizard.id = player.wizard_id
- INNER JOIN team ON team.id = player.team_id
- GROUP BY team.name HAVING COUNT(wizard.fisrtname) > 14;
- +------------+
- | name |
- +------------+
- | Gryffindor |
- | Ravenclaw |
- | Slytherin |
- +------------+
- 3 rows in set (0.01 sec)
- SELECT wizard.firstname FROM player
- INNER JOIN wizard ON wizard.id = player.wizard_id
- INNER JOIN team ON team.id = player.team_id
- WHERE team.name = 'Gryffindor' AND DAYOFWEEK(enrollment_date) = 2
- ORDER BY enrollment_date ASC;
- +-----------+
- | firstname |
- +-----------+
- | George |
- | Alice |
- | Cadogan |
- | Godric |
- | Sirius |
- | Aberforth |
- | Augusta |
- +-----------+
- 7 rows in set (0.01 sec)
- mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement