HackerRank MySQL - Weather Observation Station 5




Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.



  1. SELECT *
  2. FROM
  3. (SELECT CITY, LENGTH(CITY)
  4. FROM STATION
  5. ORDER BY LENGTH(CITY), CITY)
  6. WHERE ROWNUM = 1
  7. UNION
  8. SELECT *
  9. FROM
  10. (SELECT CITY, LENGTH(CITY)
  11. FROM STATION
  12. ORDER BY LENGTH(CITY) DESC, CITY)
  13. WHERE ROWNUM = 1;
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube