👉 https://www.hackerrank.com/challenges/weather-observation-station-5/problem?isFullScreen=true
🤔 문제 분석
1) 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, LENGTH(CITY)
FROM STATION
ORDER BY LENGTH(CITY), CITY
LIMIT 1)
UNION
(SELECT CITY, LENGTH(CITY)
FROM STATION
ORDER BY LENGTH(CITY) DESC, CITY
LIMIT 1)
'코딩테스트 > 해커랭크 SQL' 카테고리의 다른 글
[해커랭크/SQL] 12. Weather Observation Station 7 (0) | 2023.02.20 |
---|---|
[해커랭크/SQL] 11. Weather Observation Station 6 (0) | 2023.02.15 |
[해커랭크/SQL] 9. Weather Observation Station 4 (0) | 2023.02.15 |
[해커랭크/SQL] 8. Weather Observation Station 3 (0) | 2023.02.15 |
[해커랭크/SQL] 7. Japanese Cities' Attributes (0) | 2023.02.15 |
댓글