sql 查询优化。 求高手啊。 在线等。。
sql语句如下,selecttb_bill.companyno,tb_bill.custordernum,tb_bill.sid,ROW_NUMBER()over(ord...
sql语句如下,
select tb_bill.companyno,tb_bill.custordernum,tb_bill.sid,ROW_NUMBER() over (order by tb_bill.LastUpdateTime desc ) i
d,billnumber,convert(char(10),finishdate,120) finishdate,
(select COUNT(*) from TB_BillDetail where TB_BillDetail.BillSID=tb_bill.sid) species,(select sum(BookingAmount)
from TB_BillDetail where TB_BillDetail.BillSID=tb_bill.sid) [count],tb_bill.memo,billstate,TB_Customer.companyname createperson,
convert(char(16),tb_bill.createtime,120) createtime from tb_bill left join TB_Customer on
TB_Customer.SID=tb_bill.CreatePerson where tb_bill.Status = 0 order by tb_bill.createtime desc
现在我已经知道是 (select COUNT(*) from TB_BillDetail where TB_BillDetail.BillSID=tb_bill.sid) species
,(select sum(BookingAmount)
from TB_BillDetail where TB_BillDetail.BillSID=tb_bill.sid) [count],
这俩句嵌套查询拖慢了速度。 求高手高手我这段sql语句改怎么优化。 展开
select tb_bill.companyno,tb_bill.custordernum,tb_bill.sid,ROW_NUMBER() over (order by tb_bill.LastUpdateTime desc ) i
d,billnumber,convert(char(10),finishdate,120) finishdate,
(select COUNT(*) from TB_BillDetail where TB_BillDetail.BillSID=tb_bill.sid) species,(select sum(BookingAmount)
from TB_BillDetail where TB_BillDetail.BillSID=tb_bill.sid) [count],tb_bill.memo,billstate,TB_Customer.companyname createperson,
convert(char(16),tb_bill.createtime,120) createtime from tb_bill left join TB_Customer on
TB_Customer.SID=tb_bill.CreatePerson where tb_bill.Status = 0 order by tb_bill.createtime desc
现在我已经知道是 (select COUNT(*) from TB_BillDetail where TB_BillDetail.BillSID=tb_bill.sid) species
,(select sum(BookingAmount)
from TB_BillDetail where TB_BillDetail.BillSID=tb_bill.sid) [count],
这俩句嵌套查询拖慢了速度。 求高手高手我这段sql语句改怎么优化。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询