Weather Observation Station 10

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

Sol:

SELECT DISTINCT CITY FROM STATION WHERE RIGHT(CITY,1) NOT IN ('A','E','I','O','U');

Explanation:

This query retrieves distinct city names from the STATION table where the last letter of the city name is not one of the vowels 'A', 'E', 'I', 'O', or 'U'.

  • RIGHT(CITY,1): This function extracts the rightmost character of the CITY column.

  • NOT IN ('A','E','I','O','U'): This condition in the WHERE clause checks if the last letter of the CITY column is not present in the specified list of vowels ('A', 'E', 'I', 'O', 'U').

So, the query selects cities where the last letter of the city name is not a vowel.

Last updated