需要实现的SQL语句如下:
select * from(select top {0} a.companyNo as R1,a.carNo as R2,b.BeginTime as R3,b.EndTime as R4,b.SumTime as R5,b.ELongitude as R6,b.ELatitude as R7,b.EPosition as R8 from carreg a, SumCarRunTime b where a.carid=b.carid and a.CarId='{1}' and b.EndTime >= '{2}' and b.BeginTime <= '{3}'order by a.CarId,b.BeginTime) A union all Select * From (select top {0} a.companyNo as R1,a.carNo as R2,b.BeginTime as R3,b.EndTime as R4,b.SumTime as R5,b.Longitude as R6,b.Latitude as R7,b.PositionInfo as R8 from carreg a, SumCarStopTime b where a.carid=b.carid and a.CarId='{1}' and b.EndTime >= '{2}' and b.BeginTime <= '{3}'order by a.CarId,b.BeginTime) B select * from(select top {0} a
select * from(select top {0} a.companyNo as R1,a.carNo as R2,b.BeginTime as R3,b.EndTime as R4,b.SumTime as R5,b.ELongitude as R6,b.ELatitude as R7,b.EPosition as R8 from carreg a, SumCarRunTime b where a.carid=b.carid and a.CarId='{1}' and b.EndTime >= '{2}' and b.BeginTime <= '{3}'order by a.CarId,b.BeginTime) A union all Select * From (select top {0} a.companyNo as R1,a.carNo as R2,b.BeginTime as R3,b.EndTime as R4,b.SumTime as R5,b.Longitude as R6,b.Latitude as R7,b.PositionInfo as R8 from carreg a, SumCarStopTime b where a.carid=b.carid and a.CarId='{1}' and b.EndTime >= '{2}' and b.BeginTime <= '{3}'order by a.CarId,b.BeginTime) B select * from(select top {0} a