Weather Observation Station 5

  • + 0 comments

    -- create city, number of length WITH city_lengths AS ( SELECT CITY, CHAR_LENGTH(CITY) AS len FROM STATION ), -- set first condition with the longest_city longest_city AS ( SELECT CITY, len FROM city_lengths WHERE len = (SELECT MAX(len) FROM city_lengths) ORDER BY CITY ASC LIMIT 1 ), -- set second condition with the shortest_city shortest_city AS ( SELECT CITY, len FROM city_lengths WHERE len = (SELECT MIN(len) FROM city_lengths) ORDER BY CITY ASC LIMIT 1 ) -- combine them together SELECT * FROM longest_city UNION SELECT * FROM shortest_city;