Last active
October 13, 2025 15:22
-
-
Save erhaem/08decafcdaf166a386f15367b7cc8c38 to your computer and use it in GitHub Desktop.
Weather Observation Station hackerrank
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT DISTINCT city | |
| FROM station | |
| WHERE city REGEXP '^[^aeiouAEIOU]' | |
| or city REGEXP '[^aeiouAEIOU]$'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- select bagian atas: nyarii yang paling pendek | |
| (select city, length(city) | |
| from station | |
| where length(city) = ( | |
| select min(length(city)) from station | |
| ) | |
| order by city asc | |
| limit 1) | |
| union all -- buat nyatuin statement select yg atas dan bawah ini | |
| -- select bagian atas: nyarii yang paling panjang | |
| (select city, length(city) | |
| from station | |
| where length(city) = ( | |
| select max(length(city)) from station | |
| ) -- >> nyari nama city yang paling panjang | |
| order by city asc -- kalo nemu banyak, urutin secara alfabet [abcdef-wxyz] | |
| limit 1 -- dari banyak data, pilih 1 aja | |
| ) | |
| /* | |
| Output: | |
| Amo 3 | |
| Marine On Saint Croix 21 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select distinct city | |
| from station | |
| /*where city like 'a%' | |
| or city like 'i%' | |
| or city like 'u%' | |
| or city like 'e%' | |
| or city like 'o%';*/ | |
| where city REGEXP '^[aeiouAEIOU]' -- til, ternyata bisa pake regex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment