Advertisement
go6odn28

17.Monasteries by Continents and Countries

Jan 27th, 2025
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. UPDATE
  2.     countries
  3. SET
  4.     country_name = 'Burma'
  5. WHERE
  6.     country_name = 'Myanmar';
  7.    
  8. INSERT INTO
  9.     monasteries (monastery_name, country_code)
  10. VALUES
  11.     ('Hanga Abbey', (SELECT country_code FROM countries WHERE country_name = 'Tanzania')),
  12.     ('Myin-Tin-Daik', (SELECT country_code FROM countries WHERE country_name = 'Myanmar'));
  13.  
  14. SELECT
  15.     con.continent_name,
  16.     c.country_name,
  17.     count(m.id) AS monasteries_count
  18. FROM
  19.     continents AS con
  20. LEFT JOIN
  21.     countries AS c
  22. ON
  23.     c.continent_code = con.continent_code
  24. LEFT JOIN
  25.     monasteries AS m
  26. ON m.country_code = c.country_code
  27. WHERE
  28.     NOT c.three_rivers
  29. GROUP BY
  30.     c.country_name,
  31.     continent_name
  32. ORDER BY
  33.     monasteries_count DESC, country_name;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement