Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql> SELECT team.name, count(team_id) as numbers FROM player JOIN team ON team.id = player.team_id GROUP BY (team.name) ORDER BY (numbers) DESC;
- +------------+---------+
- | name | numbers |
- +------------+---------+
- | Gryffindor | 36 |
- | Slytherin | 21 |
- | Ravenclaw | 15 |
- | Hufflepuff | 12 |
- +------------+---------+
- 4 rows in set (0.00 sec)
- mysql> SELECT team.name, count(team_id) as numbers FROM player JOIN team ON team.id = player.team_id GROUP BY (team.name) having numbers >= 14 ORDER BY name;
- +------------+---------+
- | name | numbers |
- +------------+---------+
- | Gryffindor | 36 |
- | Ravenclaw | 15 |
- | Slytherin | 21 |
- +------------+---------+
- 3 rows in set (0.00 sec)
- mysql> SELECT wizard.lastname, wizard.firstname,(enrollment_date) FROM player JOIN wizard ON wizard.id = player.wizard_id WHERE team_id=1 and (enrollment_date)ASC ;
- +-----------+------------+-----------------+
- | firstname | name | enrollment_date |
- +-----------+------------+-----------------+
- | George | Gryffindor | 1991-08-26 |
- | Alice | Gryffindor | 1992-02-17 |
- | Cadogan | Gryffindor | 1993-01-04 |
- | Godric | Gryffindor | 1993-08-30 |
- | Sirius | Gryffindor | 1994-01-10 |
- | Aberforth | Gryffindor | 1995-04-24 |
- | Augusta | Gryffindor | 1999-10-25 |
- +-----------+------------+-----------------+
- 7 rows in set (0.00 sec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement