Weather Observation Station 5

  • + 0 comments

    The following is full one query to solve the problem

    '''sql

    select city,name_lenght from (

    select city,name_lenght,
        rank() over(order by name_lenght desc,city asc) as lnth_desc,
        rank() over(order by name_lenght asc,city asc) as lnth_asc
        from(
            select city,char_length(city) as name_lenght
            from station                
        ) x order by name_lenght desc
    

    ) x where lnth_asc<2 or lnth_desc<2 order by city;