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
|
7163 Discussions
|
Please Login in order to post a comment
WITH ranking AS( SELECT CITY, ROW_NUMBER() OVER (ORDER BY LENGTH(CITY) DESC, CITY) AS rnk_top, ROW_NUMBER() OVER (ORDER BY LENGTH(CITY)ASC, CITY) AS rnk_bottom FROM STATION )
SELECT CITY, LENGTH(CITY) FROM ranking WHERE rnk_top = 1 UNION SELECT CITY, LENGTH(CITY) FROM ranking WHERE rnk_bottom = 1;
Any ideas wh the commnd UNION is not processed ? i got correct answer using this but it doesn't make sense without union as those would be treated as 2 seperate executions.
SELECT TOP 1 CITY, LEN(CITY) AS LEN FROM STATION ORDER BY LEN(CITY) ASC, CITY ASC;
SELECT TOP 1 CITY, LEN(CITY) AS LEN FROM STATION ORDER BY LEN(CITY) DESC, CITY ASC;
SELECT CITY, name_length FROM ( SELECT CITY, LENGTH(CITY) as name_length, ROW_NUMBER() OVER (ORDER BY LENGTH(CITY) ASC, CITY ASC) as shortest_rank, ROW_NUMBER() OVER (ORDER BY LENGTH(CITY) DESC, CITY ASC) as longest_rank FROM STATION ) ranked WHERE shortest_rank = 1 OR longest_rank = 1;