티스토리 뷰

https://www.hackerrank.com/challenges/weather-observation-station-5

 

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

with base as (
select
    city, length(city) len
    , dense_rank() over (order by length(city), city) rn1
    , dense_rank() over (order by length(city) desc, city) rn2  
from station
)
select
    distinct city, len
from base
where rn1 = 1 or rn2 = 1

'프로그래밍연습 > SQL' 카테고리의 다른 글

[SQL]rising-temperature  (0) 2023.08.24
[SQL]confirmation-rate  (0) 2023.08.22
[SQL]exchange-seats  (0) 2023.08.21
[SQL]friend-requests-ii-who-has-the-most-friends  (0) 2023.08.20
[SQL]game-play-analysis-iv  (0) 2023.08.19
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함