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.
with CityLengths as (
Select City, Length(City) as City_Length
from Station
),
ShortestCity as (
Select City, City_Length
from CityLengths
where City_Length = (Select Min(Length(City)) from CityLengths)
order by City asc
Limit 1
),
LongestCity as(
Select City, City_Length
from CityLengths
where City_Length = (Select Max(Length(City)) from CityLengths)
order by City asc
Limit 1
)
Select City, City_Length from ShortestCity
Union All
Select City, City_Length from LongestCity
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 →
with CityLengths as ( Select City, Length(City) as City_Length from Station ), ShortestCity as ( Select City, City_Length from CityLengths where City_Length = (Select Min(Length(City)) from CityLengths) order by City asc Limit 1 ), LongestCity as( Select City, City_Length from CityLengths where City_Length = (Select Max(Length(City)) from CityLengths) order by City asc Limit 1 ) Select City, City_Length from ShortestCity Union All Select City, City_Length from LongestCity