日期:2014-05-16 浏览次数:20383 次
T21_DriverOptInfoDaily_Points的Data_Dt上创建聚集索引(没有的话)
TR_Driver的ServiceNo上创建索引(没有的话)
TR_Driver的CompanyID上创建索引(没有的话)
TR_DriverPointInfo的TR_DriverPointInfo创建索引(没有的话)
改写sql
select top 20 a.ServiceNo, a.Name, b.Seq_Points, c.Points
from TR_Driver a
left join T21_DriverOptInfoDaily_Points b on a.ServiceNo = b.ServiceNo
and b.CompanyID = a.CompanyID
left join TR_DriverPointInfo c on a.ServiceNo = c.ServiceNo
and c.CompanyID = b.CompanyID
where a.IsDelete = 0
and b.Data_Dt= '2014/2/25 10:00:00'
and c.Data_Dt= '2014/2/25 10:00:00'
and b.CompanyID = a.CompanyID
and a.ServiceNo = 843391
order by Seq_Points
select?top?20?a.ServiceNo,?a.Name,b.Seq_Points,c.Points?
from?TR_Driver?a??
left?join??
(select u.Seq_Points,u.ServiceNo,u.CompanyID from T21_DriverOptInfoDaily_Points u
inner join
(select?CompanyID?from?TR_Driver?where?ServiceNo=843391?and?IsDelete=0) v on u.CompanyID=v.CompanyID
?)b? on?a.ServiceNo=b.ServiceNo?and?b.CompanyID=a.CompanyID?
left?join?TR_DriverPointInfo?c? on?a.ServiceNo=c.ServiceNo?and?c.CompanyID=b.CompanyID?
where?a.IsDelete=0?and?DATEDIFF(SECOND,'2014/2/25?10:00:00',b.Data_Dt)=0?and?DATEDIFF(SECOND,'2014/2/25?10:00:00',c.Data_Dt)=0??
order?by?Seq_Points