Query ending with vowels using SQL LOWER() and SUBSTRING() Function

Query ending with vowels using SQL LOWER() and SUBSTRING() Function

Instructor-svg Al-Mamun Sarkar
Mar 27 , 2020

Write a SQL query to get all cities starting with vowels from the STATION table using LOWER() and SUBSTRING() functions. This is the solution of HackerRank's Weather Observation Station 7 SQL problem.

Table name: STATION

Table Structure:

Fileds Type
ID NUMBER
CITY VARCHAR
STATE VARCHAR
LAT_N NUMBER
LONG_W NUMBER

 

SQL Query:

SELECT DISTINCT CITY 
FROM STATION
WHERE LOWER(SUBSTRING(CITY, LENGTH(CITY), 1))
IN ('a', 'e', 'i', 'o', 'u');

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram