Weather Observation Station 8 in SQL | HackerRank Solution

Hello coders, today we are going to solve Weather Observation Station 8 HackerRank Solution in SQL.

Weather Observation Station 8 in SQL

Problem

Query the list of CITY names from STATION which have vowels (i.e., aeio, and u) as both their first and last characters. Your result cannot contain duplicates.

Input Format

The STATION table is described as follows:

STATION

FieldType
IDNUMBER
CITYVARCHAR2(21)
STATEVARCHAR2(2)
LAT_NNUMBER
LONG_WNUMBER

where LAT_N is the northern latitude and LONG_W is the western longitude.

Solution – Weather Observation Station 8 in SQL

MySQL

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'
)

Disclaimer: The above Problem (Weather Observation Station 8) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.

1 thought on “Weather Observation Station 8 in SQL | HackerRank Solution”

  1. cab be done in this way as well:
    select distinct(city) from station where (lower(right(city,1))) in(‘a’,’e’,’i’,’o’,’u’) and (substring(city,1,1)) in(‘a’,’e’,’i’,’o’,’u’);

Leave a Comment

Your email address will not be published. Required fields are marked *