如何在union后使用排序?

acrosslove 2002-05-28 07:11:40
我将两个select语句union后加了order by,但老报错,请问为何?谢谢
...全文
274 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
biti_rainy 2002-05-28
  • 打赏
  • 举报
回复
select * from
(
select * from ...
union all
select * from ...
) aaa
order by aaa.xxx desc;

biti_rainy 2002-05-28
  • 打赏
  • 举报
回复
select * from xxx where ....

union

select * from xxx where ....


本身的结果就是剔除重复值并排序的

union all才不排序


或者可以尝试:

select * from
(
select * from ...
union all
select * from ...
) aaa
order by aaa.

2,596

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧