문제 설명 (Difficulty: Easy)
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).
(STATION에서 CITY 이름이 가장 짧은 도시, 가장 긴 도시, 각각의 길이를 쿼리하세요. (예: 이름의 문자 수))
If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.
(1개 이상의 가장 작은 또는 가장 큰 도시가 있다면, 알파벳 순으로 정렬했을 때 먼저 나오는 항목을 선택하세요.)
The STATION table is described as follows:
(STATION 테이블은 다음과 같이 설명됩니다.)

where LAT_N is the northern latitude and LONG_W is the western longitude.
(여기서 LAT_N은 북쪽 위도이고, LONG_W는 서쪽 경도입니다.)
Sample Input
For example, CITY has four entries: DEF, ABC, PQRS and WXY.
(예를 들어, CITY 테이블은 4개 항목이 있습니다.: DEF, ABC, PQRS, WXY)
Sample Output
ABC 3
PQRS 4
Explanation
When ordered alphabetically, the CITY names are listed as ABC, DEF, PQRS, and WXY, with lengths 3, 3, 4 and 3.
(알파벳 순으로 정렬하면, CITY 이름은 ABC, DEF, PQRS, WXY로 나열되며 길이는 3, 3, 4, 3입니다.)
The longest name is PQRS, but there are 3 options for shortest named city.
(가장 이름이 긴 것은 PQRS입니다만 가장 짧은 이름의 도시는 3가지 항목(ABC, DEF, WXY)이 있습니다. )
Choose ABC, because it comes first alphabetically.
(알파벳 순으로 먼저 나오므로, ABC를 선택합니다.)
Note
You can write two separate queries to get the desired output.
(원하는 결과를 얻기 위해 두 개의 개별된 쿼리를 작성할 수 있습니다.)
It need not be a single query.
(Single 쿼리일 필요는 없습니다.)
풀이 과정 (MySQL)
'SQL > HackerRank' 카테고리의 다른 글
[HackerRank] Weather Observation Station 4 (0) | 2022.01.19 |
---|---|
[HackerRank] Weather Observation Station 3 (0) | 2022.01.19 |
[HackerRank] Weather Observation Station 1 (0) | 2022.01.19 |
[HackerRank] Japanese Cities' Names (0) | 2022.01.14 |