Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters
Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. 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.
———-SOLUTION———-
SELECT DISTINCT CITY FROM STATION WHERE SUBSTRING(CITY,1,1) in('A','E','I','O','U') AND SUBSTRING(REVERSE(CITY),1,1) in('A','E','I','O','U');
OR
SELECT DISTINCT CITY FROM STATION WHERE (CITY LIKE 'A%' OR CITY LIKE 'E%' OR CITY LIKE 'I%' OR CITY LIKE 'O%' OR CITY LIKE 'U%') AND (CITY LIKE '%a' OR CITY LIKE '%e' OR CITY LIKE '%i' OR CITY LIKE '%o' OR CITY LIKE '%u') order by city;
select distinct city
from station
where left(city, 1) in (‘a’, ‘i’, ‘e’, ‘o’, ‘u’)
and right(city, 1) in (‘a’, ‘i’, ‘e’, ‘o’, ‘u’);