Weather Observation Station 5
Data Analyst

빅데이터 관련 자료/[SQL] Basic

Weather Observation Station 5

carpe08 2021. 8. 3. 17:50
320x100
320x100

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:

 

 

 

 

 

 

# 나의 해답

 

select * from (select city c, length(city) l
from   station
order by l desc, c asc)
where rownum = 1;

select * from (select city c, length(city) l
from   station
order by l asc, c asc)
where rownum = 1;

 

 

320x100
320x100

'빅데이터 관련 자료 > [SQL] Basic' 카테고리의 다른 글

Weather Observation Station 7  (0) 2021.08.05
Weather Observation Station 6  (0) 2021.08.04
Weather Observation Station 4  (0) 2021.08.02
Weather Observation Station 3  (0) 2021.08.01
Weather Observation Station 1  (0) 2021.07.31