Help! How does this select work?

3

Help me understand how this works please.

It turns out that I'm starting the SQL studies 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 a person helped me, because I had gone up to a little more than half of this select and the end in my head I knew what I should do, but without the technical knowledge it is difficult to write.

Someone can translate what the code is doing, so I can assimilate.

    
asked by anonymous 17.05.2018 / 16:02

1 answer

1
  • FROM STATION selects data from table STATION ;
  • LOWER(CITY) will compare the column CITY with the lowercase letter;
  • REGEXP_LIKE(..., '^[aeiou]') compares if they start with vowels;
  • DISTINCT does not display duplicate results;

That is: Select all CITY of table STATION , without repetition, that start with vowels in the name;

    
17.05.2018 / 16:11