Weather Observation Station 5

  • + 0 comments

    Hacker rank is using IBM DB2 Database not PostgreSQL as mentioned. So the syntax and function name my vary. You cannot use this as same way you use mysql or postgre.

    Here is the rigth query, hope this helps.

    SELECT CITY, LENGTH(CITY) AS name_length FROM STATION ORDER BY LENGTH(CITY), CITY FETCH FIRST 1 ROWS ONLY;

    SELECT CITY, LENGTH(CITY) AS name_length FROM STATION ORDER BY LENGTH(CITY) DESC, CITY FETCH FIRST 1 ROWS ONLY;