Advertisement
peshopbs2

Untitled

Dec 8th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. ------ 5 ------
  2. SELECT card_number, job_during_journey
  3. FROM travel_cards
  4. ORDER BY card_number ASC;
  5. ------ 6 ------
  6. SELECT id,
  7. CONCAT(first_name, ' ', last_name) AS full_name,
  8. ucn
  9. FROM colonists
  10. ORDER BY first_name ASC, last_name ASC, id ASC;
  11. ------ 7 ------
  12. SELECT id, journey_start, journey_end
  13. FROM journeys
  14. WHERE purpose = 'Military'
  15. ORDER BY journey_start ASC
  16. ------ 8 ------
  17. SELECT c.id,
  18. concat(c.first_name, ' ', c.last_name) AS full_name
  19. FROM travel_cards AS tc
  20. INNER JOIN colonists AS c
  21. ON tc.colonist_id = c.id
  22. WHERE job_during_journey = 'Pilot'
  23. ORDER BY c.id ASC;
  24. ------ 9 ------
  25. SELECT
  26. ss.name AS spaceship_name,
  27. sp.name AS spaceport_name
  28. FROM journeys AS j
  29. INNER JOIN spaceports AS sp
  30. ON j.destination_spaceport_id = sp.id
  31. INNER JOIN spaceships AS ss
  32. ON j.spaceship_id = ss.id
  33. ORDER BY light_speed_rate DESC
  34. LIMIT 1
  35. ------ 10 ------
  36. SELECT
  37. p.name AS planet_name,
  38. COUNT(*) AS journeys_count
  39. FROM journeys AS j
  40. INNER JOIN spaceports AS sp
  41. ON sp.id = j.destination_spaceport_id
  42. INNER JOIN planets AS p
  43. ON sp.planet_id = p.id
  44. GROUP BY p.id
  45. ORDER BY journeys_count DESC,
  46. planet_name ASC
  47. ------ 11 ------
  48. SELECT
  49. p.name AS planet_name,
  50. COUNT(*) AS journeys_count
  51. FROM journeys AS j
  52. INNER JOIN spaceports AS sp
  53. ON sp.id = j.destination_spaceport_id
  54. INNER JOIN planets AS p
  55. ON sp.planet_id = p.id
  56. GROUP BY p.id
  57. ORDER BY journeys_count DESC,
  58. planet_name ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement