Weather Observation Station 5

Sort by

recency

|

7089 Discussions

|

  • + 0 comments

    this my solution with MsSQL server

    select distinct top 1 city , len(city) from station where len(city) < (select max(len(city)) from station) order by len(city)

    select distinct top 1 city , len(city) from station where len(city) > (select min(len(city)) from station) order by len(city) desc

  • + 0 comments

    working code SELECT CITY, LENGTH(CITY) FROM STATION ORDER BY LENGTH(CITY), CITY LIMIT 1;

    SELECT CITY, LENGTH(CITY) FROM STATION ORDER BY LENGTH(CITY) DESC, CITY LIMIT 1;

  • + 0 comments

    SELECT CITY,LENGTH(CITY) FROM STATION ORDER BY LENGTH(CITY) ASC, CITY ASC LIMIT 1; SELECT CITY,LENGTH(CITY) FROM STATION ORDER BY LENGTH(CITY) DESC, CITY ASC LIMIT 1;

  • + 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;

  • + 0 comments

    -- Shortest CITY name SELECT TOP 1 CITY, LEN(CITY) AS LEN FROM ( SELECT CITY FROM STATION ) AS Shortest ORDER BY LEN(CITY) ASC, CITY ASC;

    -- Longest CITY name SELECT TOP 1 CITY, LEN(CITY) AS LEN FROM ( SELECT CITY FROM STATION ) AS Longest ORDER BY LEN(CITY) DESC, CITY ASC;