Help! How this select works

Asked

Viewed 64 times

3

Help me understand how this works please.

I happen to be starting the 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 one person helped me because I had gone a little over half of this select and the ending in my head I knew what I should do, but without the technical knowledge it becomes difficult to write.

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

1 answer

1


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

That is: Selects all CITY table STATION, without repetition, starting with vowels in the name;

  • 1

    Thank you very much for the explanation, from there I can proceed in the studies with the understanding in the official documentation. Thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.