Anusha Murali

Logo

Please see github.com/anusha-murali for all of my repositories.

View GitHub Profile

24. Weather Observation Station 9: Solution


Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.

The STATION table is described as follows:

16

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

solution_image5

We can query using REGEXP_LIKE as follows:

SELECT DISTINCT CITY
FROM STATION
WHERE NOT REGEXP_LIKE(CITY, '^[AEIOU]');

Instead of using NOT in the WHERE clause, we can also construct the query as follows:

SELECT DISTINCT CITY
FROM STATION
WHERE REGEXP_LIKE(CITY, '^[^AEIOU]');

Explanation: [^AEIOU] looks for patterns that do not include the letters ‘A’, ‘E’, ‘I’, ‘O’, ‘U’, and '^[^AEIOU]' restricts the above exclusion to the first character of the string.


Back to problems


anusha-murali.github.io