[해커랭크] Weather Observation Station 10 / 11 / 12

june·2023년 3월 19일
0

SQL

목록 보기
5/31

Weather Observation Station 10

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

  • Query the list of CITY names from STATION that do not end with vowels. Your result cannot contain duplicates.
SELECT DISTINCT city
FROM station
WHERE city NOT LIKE '%a'
    AND city NOT LIKE '%e'
    AND city NOT LIKE '%i'
    AND city NOT LIKE '%o'
    AND city NOT LIKE '%u'

Weather Observation Station 11

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

  • Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates.
SELECT DISTINCT city
FROM station
WHERE city NOT REGEXP '^[aeiou].*'
    OR city REGEXP '.*[^aeiou]$'

Lesson & Learned

정규표현식

  • [^abc] : not a,b,c

Weather Observation Station 12

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

  • Query the list of CITY names from STATION that do not start with vowels and do not end with vowels. Your result cannot contain duplicates.
SELECT DISTINCT city
FROM station
WHERE LEFT(city, 1) NOT IN ('a', 'e', 'i', 'o', 'u')
    AND RIGHT(city, 1) NOT IN ('a', 'e', 'i', 'o', 'u')
SELECT DISTINCT city
FROM station
WHERE city NOT REGEXP '^[aeiou].*'
    AND city REGEXP '.*[^aeiou]$'
profile
나의 계절은

0개의 댓글