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.
MYSQL:
WITH VowelCities AS (
SELECT CITY,
ROW_NUMBER() OVER (PARTITION BY CITY ORDER BY CITY) AS rn
FROM STATION
WHERE
(UPPER(CITY) LIKE 'A%'
OR UPPER(CITY) LIKE 'E%'
OR UPPER(CITY) LIKE 'I%'
OR UPPER(CITY) LIKE 'O%'
OR UPPER(CITY) LIKE 'U%')
AND
(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;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 8
You are viewing a single comment's thread. Return to all comments →
MYSQL: WITH VowelCities AS ( SELECT CITY, ROW_NUMBER() OVER (PARTITION BY CITY ORDER BY CITY) AS rn FROM STATION WHERE (UPPER(CITY) LIKE 'A%' OR UPPER(CITY) LIKE 'E%' OR UPPER(CITY) LIKE 'I%' OR UPPER(CITY) LIKE 'O%' OR UPPER(CITY) LIKE 'U%') AND (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;