select city, char_length(city)
from station
order by char_length(city) desc, city 
limit 1; 

select city, char_length(city)
from station
order by char_length(city), city 
limit 1;

문제를 잘 읽자.

마지막에 이 문제의 정답의 특징을 적어 놓았다.

"You can write two separate queries to get the desired output. It need not be a single query."

 

(문제 출처 - https://www.hackerrank.com/domains/sql)

'섭섭의 공부 > SQL' 카테고리의 다른 글

[HackerRank] Weather Observation Station 8  (0) 2021.12.25
[HackerRank] Weather Observation Station 6  (0) 2021.12.25
[LeetCode] Consecutive Numbers  (0) 2021.12.24
[HackerRank] The Report  (0) 2021.12.24
[LeetCode] Department Highest Salary  (0) 2021.12.24

+ Recent posts