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.

 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:


SOLUTION :

SELECT DISTINCT CITY FROM STATION WHERE

LOWER(SUBSTR(CITY , 1,1)) IN('a','e','i','o','u') and 

LOWER(SUBSTR(CITY,-1,1)) IN('a','e','i','o','u');


EXPLANATION :

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

  • SUBSTR(CITY, -1, 1): Gets the last character.

  • LOWER(...): Makes it case-insensitive.

  • IN ('a', 'e', 'i', 'o', 'u'): Checks for vowels.

  • DISTINCT: Removes duplicates.

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.