Question:
Help me understand how this works please.
It turns out that I'm starting studies in SQL and hackerhank
has an exercise that needed this code:
SELECT DISTINCT CITY FROM STATION WHERE REGEXP_LIKE(LOWER(CITY), '^[aeiou]') ;
After a lot of effort and someone helped me, as I had gone to a little more than half of this select
and the end in my head I knew what to do, but without technical knowledge it is difficult to write.
Can someone translate what the code is doing so I can assimilate.
Answer:
-
FROM STATION
selects data from theSTATION
table; -
LOWER(CITY)
will compare theCITY
column with the lowercase letter; -
REGEXP_LIKE(..., '^[aeiou]')
compares if they start with vowels; -
DISTINCT
does not show duplicate results;
In other words: Selects all CITY
from the STATION
table, without repetition, that start with vowels in the name;