Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. Database changed
  2.  
  3. SELECT team.name, COUNT(wizard.firstname)
  4. AS nbplayer FROM player
  5. INNER JOIN wizard ON wizard.id = player.wizard_id
  6. INNER JOIN team ON team.id = player.team_id
  7. GROUP BY team.name ORDER BY nbplayer DESC;
  8.  
  9. +------------+----------+
  10. | name | nbplayer |
  11. +------------+----------+
  12. | Gryffindor | 36 |
  13. | Slytherin | 21 |
  14. | Ravenclaw | 15 |
  15. | Hufflepuff | 12 |
  16. +------------+----------+
  17. 4 rows in set (0.00 sec)
  18.  
  19. SELECT team.name FROM player
  20. INNER JOIN wizard ON wizard.id = player.wizard_id
  21. INNER JOIN team ON team.id = player.team_id
  22. GROUP BY team.name HAVING COUNT(wizard.fisrtname) > 14;
  23.  
  24. +------------+
  25. | name |
  26. +------------+
  27. | Gryffindor |
  28. | Ravenclaw |
  29. | Slytherin |
  30. +------------+
  31. 3 rows in set (0.01 sec)
  32.  
  33. SELECT wizard.firstname FROM player
  34. INNER JOIN wizard ON wizard.id = player.wizard_id
  35. INNER JOIN team ON team.id = player.team_id
  36. WHERE team.name = 'Gryffindor' AND DAYOFWEEK(enrollment_date) = 2
  37. ORDER BY enrollment_date ASC;
  38.  
  39. +-----------+
  40. | firstname |
  41. +-----------+
  42. | George |
  43. | Alice |
  44. | Cadogan |
  45. | Godric |
  46. | Sirius |
  47. | Aberforth |
  48. | Augusta |
  49. +-----------+
  50. 7 rows in set (0.01 sec)
  51.  
  52. mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement