Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.03 KB | None | 0 0
  1. SELECT
  2.     co.continent_code,
  3.     (SELECT
  4.             cr.currency_code
  5.         FROM
  6.             currencies AS cr
  7.                 INNER JOIN
  8.             countries AS cou ON cou.currency_code = cr.currency_code
  9.         WHERE
  10.             co.continent_code = cou.continent_code
  11.         GROUP BY cr.currency_code
  12.         ORDER BY COUNT(cr.currency_code) DESC
  13.         LIMIT 1) AS most,
  14.     (SELECT
  15.             count(cr.currency_code)
  16.         FROM
  17.             currencies AS cr
  18.                 INNER JOIN
  19.             countries AS cou ON cou.currency_code = cr.currency_code
  20.         WHERE
  21.             co.continent_code = cou.continent_code
  22.         GROUP BY cr.currency_code
  23.         ORDER BY COUNT(cr.currency_code) DESC
  24.         LIMIT 1) AS number_of_currencies
  25. FROM
  26.     continents AS co
  27.         INNER JOIN
  28.     countries AS c ON c.continent_code = co.continent_code
  29.         INNER JOIN
  30.     currencies AS cu ON c.currency_code = c.currency_code
  31. GROUP BY most
  32. HAVING number_of_currencies > 1
  33. ORDER BY co.continent_code ASC , most ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement