select CITY, LENGTH(CITY)
from STATION
ORDER BY LENGTH(CITY), CITY
LIMIT 1;
select CITY, LENGTH(CITY)
from STATION
ORDER BY LENGTH(CITY) DESC, CITY
LIMIT 1;
choose the one that comes first이므로 내림차순으로 정렬한뒤에 LIMIT를 사용해서 1개만 불러온다.
'Algorithm > SQL' 카테고리의 다른 글
[SQL][HackerRank] Weather Observation Station 8 (0) | 2020.06.08 |
---|---|
[SQL][HackerRank] Weather Observation Station 6 (0) | 2020.06.08 |
[SQL][HackerRank] Weather Observation Station 4 (0) | 2020.06.08 |
[SQL][HackerRank] Weather Observation Station 3 (0) | 2020.06.08 |
[SQL][HackerRank] Weather Observation Station 1 (0) | 2020.06.08 |