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.
Weather Observation Station 5
Weather Observation Station 5
Sort by
recency
|
7256 Discussions
|
Please Login in order to post a comment
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;
SELECT CITY, LENGTH(CITY) AS LEN FROM STATION ORDER BY LEN ASC, CITY ASC LIMIT 1; SELECT CITY, LENGTH(CITY) AS LEN FROM STATION ORDER BY LEN DESC, CITY ASC LIMIT 1;
(select city,length(city) from station order by length(city),city limit 1) UNION (select city,length(city) from station order by length(city) desc,city limit 1)
with cte as( select city, row_number() over(order by length(city), c``ity) as rn from station ) select city, length(city) from cte where rn =1 or rn = (select max(rn) from cte)------MySQL
This will solve the problem in single query using window function
With CTE as (SELECT city,length(city),row_number() over (order by length(city) desc,city ) as rw from Station Union SELECT city,length(city),row_number() over (order by length(city),city ) as rw from Station )
select city,length(city) from CTE where rw =1