프로그래머스
[StrataScractch] Number Of Units Per Nationality [MySQL]
치킨먹고싶어요
2022. 6. 25. 00:54
https://platform.stratascratch.com/coding/10156-number-of-units-per-nationality?code_type=3
StrataScratch
platform.stratascratch.com
WITH UNDER_30 AS (
SELECT DISTINCT(host_id), nationality
FROM airbnb_hosts
WHERE age < 30
)
select nationality, COUNT(*)
FROM UNDER_30
LEFT OUTER JOIN airbnb_units
ON airbnb_units.host_id = UNDER_30.host_id
WHERE airbnb_units.unit_type = "apartment"
GROUP BY nationality
ORDER BY COUNT(*) DESC;
|
cs |