Hackerrank – Weather Observation Station 5

Problem Statement
A description of the problem can be found on Hackerrank.

Solution
2 queries:
One that selects cities that are ordered by city length ascending and printed first row containing city and its length.
Second is almost the same as first but cities are ordered descending.

In both queries I used second ordering by name alphabetically ascending because of condition ‘if there are more than one possible cities print the lexicographical smallest.’

I created solution in:

All solutions are also available on my GitHub.

SQL