社区
疑难问题
帖子详情
如何对union后的结果排序呢?
xatop
2003-10-20 02:44:39
如何对union后的结果排序呢?
...全文
133
8
打赏
收藏
如何对union后的结果排序呢?
如何对union后的结果排序呢?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
lijinqiang
2003-10-20
打赏
举报
回复
SELECT ID ,XM ... FROM TABEL1 WHERE ... GROUP BY ID,XM
UNION ALL
SELECT ID ,XM ... FROM TABEL2 WHERE ... GROUP BY ID,XM
xatop
2003-10-20
打赏
举报
回复
无人可以解决,已经别处征集高手,此贴作废!
xatop
2003-10-20
打赏
举报
回复
服务器: 消息 8626,级别 16,状态 1,行 1
在工作表中只允许有 text 指针,而决不允许有 text、ntext 或 image 列。
xatop
2003-10-20
打赏
举报
回复
sql="select * from (select id,clss,title,timein from t1 union all select id,clss,title,timein from t2 where rootcl=8) a order by timein desc"
错误!!!!!!!!!!
sql="select id,clss,title,timein from zwgg union all select id,clss,title,timein from jttnew where rootcl=8 order by timein desc"
错误!!!!!!!!!!
aierong
2003-10-20
打赏
举报
回复
如果使用 UNION 运算符,那么单独的 SELECT 语句不能包含其自己的 ORDER BY 或 COMPUTE 子句。只能在最后一个 SELECT 语句的后面使用一个 ORDER BY 或 COMPUTE 子句;该子句适用于最终的组合结果集。GROUP BY 和 HAVING 子句只能在单独的 SELECT 语句中指定。
aierong
2003-10-20
打赏
举报
回复
select a,b from tablea
union
select a,b from tableb
order by 排序的字段
在最后一个语句后加排序子句,这个子句可以影响整个结果
yujohny
2003-10-20
打赏
举报
回复
select * from
(select 11 as a,2 as b
union select 4,3
union select 3,5) T
order by a
sdhdy
2003-10-20
打赏
举报
回复
select * from
(select a,b from tablea
union
select a,b from tableb) a order by a
疑难问题
22,209
社区成员
121,730
社区内容
发帖
与我相关
我的任务
疑难问题
MS-SQL Server 疑难问题
复制链接
扫一扫
分享
社区描述
MS-SQL Server 疑难问题
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章