SQL & DB/HackerRank SQL Problem

[HackerRank SQL] Weather Observation Station 5, 6(MySQL)

YSY^ 2021. 2. 27. 17:39

www.hackerrank.com/challenges/weather-observation-station-5/problem

 

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

Answer

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;

 


www.hackerrank.com/challenges/weather-observation-station-6/problem

 

Weather Observation Station 6 | HackerRank

Query a list of CITY names beginning with vowels (a, e, i, o, u).

www.hackerrank.com

select city
from station
where city regexp '^[aeiou]' 

정규표현식을 사용한다.

MySQL에서 정규표현식은 regexp이다.

 

728x90
반응형