Im between cherry

Hackerrank | MySQL | Weather Observation Station 11 본문

데이터분석/practice_query

Hackerrank | MySQL | Weather Observation Station 11

meal 2020. 8. 28. 09:10

Weather Observation Station 11

Problem

 

Weather Observation Station 11 | HackerRank

Query a list of CITY names not starting or ending with vowels.

www.hackerrank.com

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.

 

 

Solution

SELECT DISTINCT CITY
FROM STATION
WHERE SUBSTR(CITY,1,1) NOT IN ('a','e','i','o','u') or
	SUBSTR(CITY,-1,1) NOT IN ('a','e','i','o','u');
SELECT DISTINCT city
FROM station
WHERE city NOT REGEXP '^[aeiou]'
   OR city NOT REGEXP '[aeiou]$'
SELECT DISTINCT city 
FROM station
WHERE city NOT RLIKE '^[aeiouAEIOU]' 
OR city NOT RLIKE '[aeiouAEIOU]$'
SELECT Distinct City
FROM Station
WHERE City NOT rLike '^[aeoui]'
OR City NOT rLike '[aeoiu]$'
SELECT DISTINCT CITY
FROM STATION
WHERE city not rlike "^[aeiouAEIOU].*[aeiou]$"
Comments