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.
SELECT CITY, length(LTRIM(RTRIM(City))) FROM (
SELECT CITY
, rank() OVER ( PARTITION BY length(LTRIM(RTRIM(City))) ORDER BY CITY) as rankk
FROM STATION
WHERE length(LTRIM(RTRIM(City))) = (select Min(length(LTRIM(RTRIM(City)))) as SHORT from station )
OR length(LTRIM(RTRIM(City))) = (select MAX(length(LTRIM(RTRIM(City)))) as LONGEST from station )
) ab WHERE rankk = 1;
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 →
Mine
SELECT CITY, length(LTRIM(RTRIM(City))) FROM ( SELECT CITY , rank() OVER ( PARTITION BY length(LTRIM(RTRIM(City))) ORDER BY CITY) as rankk FROM STATION WHERE length(LTRIM(RTRIM(City))) = (select Min(length(LTRIM(RTRIM(City)))) as SHORT from station ) OR length(LTRIM(RTRIM(City))) = (select MAX(length(LTRIM(RTRIM(City)))) as LONGEST from station ) ) ab WHERE rankk = 1;