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.
MySQl
Solution 1:
SELECT DISTINCT CITY FROM STATION WHERE RIGHT(CITY,1) IN ('a','i','e','o','u') and city REGEXP "^[aeiou].*";
Solution2:
select distinct city from station where left(city,1) in ('a','e','i','o','u') and right(city, 1) in ('a','e','i','o','u')
Solution 3:
SELECT DISTINCT CITY FROM STATION WHERE CITY REGEXP '^[aeiou].*[aeiou]$';
Oracle:
SELECT city
FROM station
WHERE (
LOWER(city) LIKE 'a%'
OR LOWER(city) LIKE 'e%'
OR LOWER(city) LIKE 'i%'
OR LOWER(city) LIKE 'o%'
OR LOWER(city) LIKE 'u%'
)
AND (
LOWER(city) LIKE '%a'
OR LOWER(city) like '%e'
OR LOWER(city) LIKE '%i'
OR LOWER(city) LIKE '%o'
OR LOWER(city) LIKE '%u'
);
Post a Comment