这为什么不能给出预期的结果?
SELECT top 1 CITY, LEN(CITY) FROM STATION ORDER BY LEN (city) desc
union all
SELECT top 1 CITY, LEN(CITY) FROM STATION ORDER BY LEN (city) asc;
答案 0 :(得分:1)
您需要将每个有序查询表示为子查询,因为union
无法跟随order by
,因此:
select a.* from (select top 1 city, len(city) from station order by len(city) desc) a
union all
select b.* from (select top 1 city, len(city) from station order by len(city)) b