sqlserver多个查询语句执行问题
在不排序情况下
select top 5 * from table where nid=1
union all
select top 10 * from table where nid=2
这个sql语句能运行
select top 5 * from table where nid=1 order by id desc
union all
select top 10 * from table where nid=2 order by id desc
排序就不能正确运行
求 怎么改成在排序下也能运行
[解决办法]
select * from (select top 5 * from ..........)
union all
select * from (select top 10 * from ............)
[解决办法]
select * from (
select top 5 * from table where nid=1
union all
select top 10 * from table where nid=2)a
order by id desc
[解决办法]
不过你最好首先解决“怎样让其不排序”的问题,实在不能解决,明白了白白浪费时间去排序的风险责任,再这样写。
[解决办法]