为什么子查询里面使用 order by 会出错的?

lazybone 2004-05-08 11:38:59
为什么子查询里面使用 order by 会出错的?
select * from table2
where age in (select age from table2 where age>44 order by age)order by age
...全文
143 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
internetcsdn 2004-05-08
  • 打赏
  • 举报
回复
select * from table2
where age in
(select distinct age from table2 where age>44 ) order by age

这样可以啊
lazybone 2004-05-08
  • 打赏
  • 举报
回复
同样在子查询里面不能用 distinct 是不是这样原因?
internetcsdn 2004-05-08
  • 打赏
  • 举报
回复
错误提示里好明显地提到啦,
如果你一定要用的话试下.

select * from table2
where age in
(select top 1000 age from table2 where age>44 order by age)order by age
lazybone 2004-05-08
  • 打赏
  • 举报
回复
但也不应该错啊. 最多是做事画蛇添足罢了
internetcsdn 2004-05-08
  • 打赏
  • 举报
回复
order by 在你的子查询里没有什么意义
internetcsdn 2004-05-08
  • 打赏
  • 举报
回复
select * from table2
where age in
(select age from table2 where age>44 )order by age

在子查询里用不着用到order by 啊

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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