Hello coders, today we are going to solve Weather Observation Station 11 HackerRank Solution in SQL.
Problem
Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates.
Input Format
The STATION table is described as follows:
STATION
Field | Type |
ID | NUMBER |
CITY | VARCHAR2(21) |
STATE | VARCHAR2(2) |
LAT_N | NUMBER |
LONG_W | NUMBER |
where LAT_N is the northern latitude and LONG_W is the western longitude.
Solution – Weather Observation Station 11 in SQL
MySQL
select distinct city from station where not (city like 'A%' or city like 'E%' or city like 'I%' or city like 'O%' or city like 'U%') or not (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 9) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.
In the query replace ‘or’ with ‘and’ then it will satisfy both conditions.