Advertisement
Gaela

Untitled

Dec 12th, 2021
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.44 KB | None | 0 0
  1. mysql> SELECT team.name , COUNT(player.id) AS total FROM player JOIN team ON player.team_id = team.id GROUP BY team.id ORDER BY total DESC;
  2. +------------+-------+
  3. | name       | total |
  4. +------------+-------+
  5. | Gryffindor |    36 |
  6. | Slytherin  |    21 |
  7. | Ravenclaw  |    15 |
  8. | Hufflepuff |    12 |
  9. +------------+-------+
  10. 4 rows IN SET (0.01 sec)
  11.  
  12.  
  13. mysql> SELECT team.name , COUNT(player.id) AS total FROM player JOIN team ON player.team_id = team.id GROUP BY team.id HAVING total >=14 ORDER BY team.name;
  14. +------------+-------+
  15. | name       | total |
  16. +------------+-------+
  17. | Gryffindor |    36 |
  18. | Ravenclaw  |    15 |
  19. | Slytherin  |    21 |
  20. +------------+-------+
  21. 3 rows IN SET (0.01 sec)
  22.  
  23.  
  24.  
  25. mysql> SELECT wizard.firstname,team.name,enrollment_date FROM player JOIN team ON player.team_id = team.id JOIN wizard ON player.wizard_id = wizard.id WHERE team.name = "Gryffindor" AND DAYOFWEEK(enrollment_date)= 2 ORDER BY enrollment_date;
  26. +------------+------------+-----------------+
  27. | firstname  | name       | enrollment_date |
  28. +------------+------------+-----------------+
  29. | Weasley    | Gryffindor | 1991-08-26      |
  30. | Longbottom | Gryffindor | 1992-02-17      |
  31. |            | Gryffindor | 1993-01-04      |
  32. | Gryffindor | Gryffindor | 1993-08-30      |
  33. | Black      | Gryffindor | 1994-01-10      |
  34. | Dumbledore | Gryffindor | 1995-04-24      |
  35. | Longbottom | Gryffindor | 1999-10-25      |
  36. +------------+------------+-----------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement