We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Weather Observation Station 11
Weather Observation Station 11
Sort by
recency
|
3673 Discussions
|
Please Login in order to post a comment
MYSQL: WITH VowelCities AS ( SELECT DISTINCT CITY, ROW_NUMBER() OVER (PARTITION BY CITY ORDER BY CITY) AS rn FROM STATION WHERE NOT (UPPER(CITY) LIKE 'A%' OR UPPER(CITY) LIKE 'E%' OR UPPER(CITY) LIKE 'I%' OR UPPER(CITY) LIKE 'O%' OR UPPER(CITY) LIKE 'U%') OR NOT (UPPER(CITY) LIKE '%A' OR UPPER(CITY) LIKE '%E' OR UPPER(CITY) LIKE '%I' OR UPPER(CITY) LIKE '%O' OR UPPER(CITY) LIKE '%U') ) SELECT CITY FROM VowelCities WHERE rn = 1;
Approach - 1 (REGEXP)
SELECT DISTINCT CITY FROM STATION WHERE CITY NOT REGEXP '^[aeiou]' OR CITY NOT REGEXP '[aeiou]$'
Approach - 2 (SUBSTRING)
SELECT DISTINCT CITY FROM STATION WHERE SUBSTRING(CITY, 1, 1) NOT IN ('a', 'e', 'i', 'o', 'u') OR SUBSTRING(CITY, -1, 1) NOT IN ('a', 'e', 'i', 'o', 'u')
NOTE: Instead of -1, you can use LENGTH(CITY)
Approach - 3 (LEFT & RIGHT FUNCTION)
SELECT DISTINCT CITY FROM STATION WHERE LEFT(CITY, 1) NOT IN ('a', 'e', 'i', 'o', 'u') OR RIGHT(CITY, 1) NOT IN ('a', 'e', 'i', 'o', 'u')
Approach - 4 (LIKE OPERATOR)
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%') OR (CITY NOT LIKE '%a' AND CITY NOT LIKE '%e' AND CITY NOT LIKE '%i' AND CITY NOT LIKE '%o' AND CITY NOT LIKE '%u');
P.S. All above operators (IN, LIKE, REGEXP) used are case insensitive, so no need to write 'a' and 'A', simply 'a' will do the work for both the cases
Upvote if it helped :)
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%' )or( city not like '%a' and city not like '%e' and city not like '%i' and city not like '%o' and city not like '%u')
give a try
select distinct city from station where left(city,1) not in ('a','e','i','o','u') or right(city,1) not in ('a','e','i','o','u');
Oracle - It is expecting either do not start with vowels or do not end with vowels.
select distinct(city) from station where lower(substr(city,1,1)) Not In ('a','i','e','o','u') or lower(substr(city, -1,1)) Not In ('a','i','e','o','u');