KechevD

SQL_изпитване26.05.20

May 26th, 2020
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. SELECT students.name,class,s.name,sg.location,sg.hourOfTraining,sg.dayOfWeek,c.name FROM students
  2. JOIN student_sport ss on students.id = ss.student_id
  3. JOIN sportGroups sG on ss.sportGroup_id = sG.id
  4. JOIN sports s on sG.sport_id = s.id
  5. JOIN coaches c on sG.coach_id = c.id
  6. WHERE s.name = 'Volleyball';
  7.  
  8.  
  9. SELECT coaches.name,sG.id,s.name,s2.class,sg.dayOfWeek FROM coaches
  10. JOIN sportGroups sG on coaches.id = sG.coach_id
  11. JOIN sports s on sG.sport_id = s.id
  12. JOIN student_sport ss on sG.id = ss.sportGroup_id
  13. JOIN students s2 on ss.student_id = s2.id
  14. WHERE s2.class = '11'
  15. ORDER BY
  16. case dayOfWeek
  17. when 'Monday' then 1
  18. when 'Tuesday' then 2
  19. when 'Wednesday' then 3
  20. when 'Thursday' then 4
  21. when 'Friday' then 5
  22. when 'Saturday' then 6
  23. when 'Sunday' then 7
  24. end ;
Add Comment
Please, Sign In to add comment