Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.

Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.

Input Format

The STATION table is described as follows:


SOLUTION : 

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%';


EXPLANATION : 

  • DISTINCT: Ensures no duplicate city names are returned.

  • SUBSTR(CITY, 1, 1): Gets the first character of the city name.

  • LOWER(...): Converts the first character to lowercase for a case-insensitive comparison.

  • IN ('a', 'e', 'i', 'o', 'u'): Filters cities that start with a vowel.


Popular posts from this blog

When a method in a subclass overrides a method in superclass, it is still possible to call the overridden method using super keyword - Hacker Rank Solution.

You are given a date. You just need to write the method getDay which returns the day on that date - Hacker Rank Solution.