Pavithra's Space
  • Home
  • Skills
    • SQL
    • HackerRank
      • Revising the Select Query I
      • Revising the Select Query II
      • Select All
      • Select By ID
      • Japanese Cities' Attributes
      • Japanese Cities' Names
      • Weather Observation Station 1
      • Weather Observation Station 3
      • Weather Observation Station 4
      • Weather Observation Station 5
      • Weather Observation Station 6
      • Weather Observation Station 7
      • Weather Observation Station 8
      • Weather Observation Station 9
      • Weather Observation Station 10
      • Weather Observation Station 11
      • Weather Observation Station 12
      • Higher Than 75 Marks
      • Employee Names
      • Employee Salaries
Powered by GitBook
On this page
  1. Skills
  2. HackerRank

Weather Observation Station 9

PreviousWeather Observation Station 8NextWeather Observation Station 10

Last updated 1 year ago

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

Sol:

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

Explanation:

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

  • LEFT(CITY,1): This function extracts the leftmost character of the CITY column.

  • NOT IN ('A','E','I','O','U'): This condition in the WHERE clause checks if the first 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 first letter of the city name is not a vowel.

Weather Observation Station 9 | HackerRankHackerRank
Logo