Last active
July 25, 2024 18:00
-
-
Save leonardobrito/d2163e035ba27aab9d146aa4fb2c6468 to your computer and use it in GitHub Desktop.
sqls
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 id % 2 = 0; // even | |
| select distinct city from station where mod(id, 2) = 0; // even | |
| select distinct city from station where id % 2 <> 0; // odd | |
| // City Min and Max length alfabeticaly ordered. | |
| select city, LENGTH(city) from station | |
| where LENGTH(city) = (select MIN(LENGTH(city)) from station) | |
| order by city limit 1; | |
| select city, LENGTH(city) from station | |
| where LENGTH(city) = (select MAX(LENGTH(city)) from station) | |
| order by city limit 1; | |
| SELECT CITY, LENGTH(CITY) | |
| FROM STATION | |
| ORDER BY LENGTH(CITY) ASC, CITY ASC | |
| LIMIT 1; | |
| SELECT CITY, LENGTH(CITY) | |
| FROM STATION | |
| ORDER BY LENGTH(CITY) DESC, CITY ASC | |
| LIMIT 1; | |
| // List from vowels first and last chars in city | |
| select distinct city from station where right(city, 1) in ("a", "e", "i", "o", "u") | |
| select distinct city from station where left(city, 1) in ("a", "e", "i", "o", "u") | |
| select distinct city from station where substring(city, 1, 1) in ("a", "e", "i", "o", "u") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment