728x90
반응형
문제 : Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.

SELECT CITY, CHAR_LENGTH(CITY)
FROM STATION
ORDER BY CHAR_LENGTH(CITY) ASC, CITY ASC
LIMIT 1;
SELECT CITY, CHAR_LENGTH(CITY)
FROM STATION
ORDER BY CHAR_LENGTH(CITY) DESC, CITY ASC
LIMIT 1;
Amo 3
Marine On Saint Croix 21
728x90
반응형
'DB > SQL' 카테고리의 다른 글
| HackerRank_13. Weather Observation Station 7 (0) | 2020.06.11 |
|---|---|
| HackerRank_12. Weather Observation Station 6 (0) | 2020.06.11 |
| HackerRank_10. Weather Observation Station 4 (0) | 2020.06.11 |
| HackerRank_09. Weather Observation Station 3 (0) | 2020.06.11 |
| HackerRank_08. Weather Observation Station 2 (0) | 2020.06.11 |