Hello coders, today we are going to solve Weather Observation Station 6 HackerRank Solution in SQL.
Problem
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:
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 6 in SQL
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%";
Disclaimer: The above Problem (Weather Observation Station 6) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.
its not working
Try the following
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%’;
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%’;
select DISTINCT CITY
from STATION
where regexp_like(CITY, ‘^[AEIOU]’);
SELECT DISTINCT CITY
FROM STATION
WHERE LEFT(CITY,1) IN (‘A’,’E’,’I’,’O’,’U’);