Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE IF NOT EXISTS `continents_currencies` AS SELECT `c`.`continent_code`,
- `c`.`currency_code`,
- COUNT(`c`.`currency_code`) AS `currency_usage` FROM
- `countries` AS `c`
- GROUP BY `c`.`continent_code`,`c`.`currency_code`
- HAVING `currency_usage` > 1
- ORDER BY `c`.`continent_code` , `c`.`currency_code`;
- SELECT
- `cc`.*
- FROM
- `continents_currencies` AS `cc`
- LEFT JOIN
- `continents_currencies` AS `cc2` ON `cc`.`continent_code` = `cc2`.`continent_code`
- AND `cc`.`currency_usage` < `cc2`.`currency_usage`
- WHERE
- `cc2`.`currency_usage` IS NULL;
- DROP TABLE `continents_currencies`;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement