We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 5
You are viewing a single comment's thread. Return to all 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;