是这样吗????
select *
from (select szb.id,drive.cargoid,szb.income,szb.payout,szb.qtfy,szb.memo,szb.num,szb.adde,szb.carname,szb.driveid ,drive.carid from szb,drive where szb.num=1 and szb.adde='苏' and drive.driveid = szb.driveid order by szb.driveid desc) AA
where (cargoid in
(select cargoid
from (select szb.id,drive.cargoid,szb.income,szb.payout,szb.qtfy,szb.memo,szb.num,szb.adde,szb.carname,szb.driveid ,drive.carid from szb,drive where szb.num=1 and szb.adde='苏' and drive.driveid = szb.driveid order by szb.driveid desc) AA
group by cargoid
having count(*) > 1))
order by cargoid
select *
from (select szb.id,drive.cargoid,szb.income,szb.payout,szb.qtfy,szb.memo,szb.num,szb.adde,szb.carname,szb.driveid ,drive.carid from szb,drive where szb.num=1 and szb.adde='苏' and drive.driveid = szb.driveid order by szb.driveid desc) AA
where (cargoid in
(select cargoid
from (select szb.id,drive.cargoid,szb.income,szb.payout,szb.qtfy,szb.memo,szb.num,szb.adde,szb.carname,szb.driveid ,drive.carid from szb,drive where szb.num=1 and szb.adde='苏' and drive.driveid = szb.driveid order by szb.driveid desc) AA
group by cargoid
having count(*) > 1))
order by cargoid
除非同时指定了 TOP,否则 ORDER BY 子句在视图、内嵌函数、派生表和子查询中无效。
服务器: 消息 1033,级别 15,状态 1,行 7
除非同时指定了 TOP,否则 ORDER BY 子句在视图、内嵌函数、派生表和子查询中无效。
select *
from (select szb.id,drive.cargoid,szb.income,szb.payout,szb.qtfy,szb.memo,szb.num,szb.adde,szb.carname,szb.driveid ,drive.carid from szb,drive where szb.num=1 and szb.adde='苏' and drive.driveid = szb.driveid order by szb.driveid desc)
where (cargoid in
(select cargoid
from (select szb.id,drive.cargoid,szb.income,szb.payout,szb.qtfy,szb.memo,szb.num,szb.adde,szb.carname,szb.driveid ,drive.carid from szb,drive where szb.num=1 and szb.adde='苏' and drive.driveid = szb.driveid order by szb.driveid desc)
group by cargoid
having count(*) > 1))
order by cargoid原话复制!
如果你一定要用order by 就指定一个top n,n大于列出的行数就可以了
select *
from (select top 1000 szb.id,drive.cargoid,szb.income,szb.payout,szb.qtfy,szb.memo,szb.num,szb.adde,szb.carname,szb.driveid ,drive.carid from szb,drive where szb.num=1 and szb.adde='苏' and drive.driveid = szb.driveid order by szb.driveid desc)
where (cargoid in
(select cargoid
from (select top 1000 szb.id,drive.cargoid,szb.income,szb.payout,szb.qtfy,szb.memo,szb.num,szb.adde,szb.carname,szb.driveid ,drive.carid from szb,drive where szb.num=1 and szb.adde='苏' and drive.driveid = szb.driveid order by szb.driveid desc)
group by cargoid
having count(*) > 1))
order by cargoid但是这样呀
服务器: 消息 156,级别 15,状态 1,行 3
在关键字 'where' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,行 6
在关键字 'group' 附近有语法错误。
select szb.id,drive.cargoid,szb.income,szb.payout,szb.qtfy,szb.memo,szb.num,szb.adde,szb.carname,szb.driveid ,drive.carid into #temp from szb,drive where szb.num=1 and szb.adde='苏' and drive.driveid = szb.driveid order by szb.driveid descselect *
from #temp1
where (cargoid in
(select cargoid
from szb
group by #temp1
having count(*) > 1))
order by cargoiddrop table #temp