https://www.hackerrank.com/challenges/weather-observation-station-5/problem?isFullScreen=true
Weather Observation Station 5 | HackerRank
Write a query to print the shortest and longest length city name along with the length of the city names.
www.hackerrank.com
문제
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.
The STATION table is described as follows:

where LAT_N is the northern latitude and LONG_W is the western longitude.
Code
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;
'SQL > MySQL' 카테고리의 다른 글
[MySQL/HackerRank] Occupations (0) | 2023.08.29 |
---|---|
[MySQL/HackerRank] The Report (0) | 2023.08.29 |
[MySQL/HackerRank] Draw The Triangle 2 (0) | 2023.08.29 |
[MySQL/HackerRank] Draw The Triangle 1 (0) | 2023.08.29 |
[MySQL/HackerRank] Weather Observation Station 19 (0) | 2023.08.25 |
https://www.hackerrank.com/challenges/weather-observation-station-5/problem?isFullScreen=true
Weather Observation Station 5 | HackerRank
Write a query to print the shortest and longest length city name along with the length of the city names.
www.hackerrank.com
문제
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.
The STATION table is described as follows:

where LAT_N is the northern latitude and LONG_W is the western longitude.
Code
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;
'SQL > MySQL' 카테고리의 다른 글
[MySQL/HackerRank] Occupations (0) | 2023.08.29 |
---|---|
[MySQL/HackerRank] The Report (0) | 2023.08.29 |
[MySQL/HackerRank] Draw The Triangle 2 (0) | 2023.08.29 |
[MySQL/HackerRank] Draw The Triangle 1 (0) | 2023.08.29 |
[MySQL/HackerRank] Weather Observation Station 19 (0) | 2023.08.25 |