HackerRank/SQL

[hackerrank] Weather Observation Station 6

예쁜꽃이피었으면 2022. 8. 8. 16:38

[hackerrank] Prepare > SQL > Basic Select >  Weather Observation Station 6

 

[문제]

Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.

Input Format

The STATION table is described as follows:

where LAT_N is the northern latitude and LONG_W is the western longitude.

 

[MYSQL]

 

 

[ORCALE]

-- 1차
-- select city
-- from station
-- where substr(city,0,1) = 'A' 
-- or  substr(city,0,1) = 'E'
-- or  substr(city,0,1) = 'I'
-- or  substr(city,0,1) = 'O'
-- or  substr(city,0,1) = 'U';


-- 2차
-- select city
-- from station
-- where city like 'A%' 
-- or  city like 'E%'
-- or  city like 'I%'
-- or  city like 'O%'
-- or  city like 'U%';

--3차
-- select city
-- from station
-- where regexp_like(city,'^A|^E|^I|^O|^U');

--4차
select city
from station
where regexp_like(city,'^a|^e|^i|^o|^u','i');

 

 

 

반응형