我试图执行下面的代码,这是太多的时间来执行。
SELECT
ROW_NUMBER() OVER (PARTITION BY a.DeviceID, a.SubscriberLoginID ORDER BY a.GPSCommandID) Row,
a.DeviceId,
SubscriberLoginID,
CabLatitude, CabLongitude,
LEAD(CabLatitude) OVER (PARTITION BY a.DeviceId, SubscriberLoginID ORDER BY CONVERT(DATETIME, GPSDateTime)) NextLat,
LEAD(CabLongitude) OVER (PARTITION BY a.DeviceId, SubscriberLoginID ORDER BY CONVERT(DATETIME, GPSDateTime)) NextLong,
MeterStatusId,
LEAD(MeterStatusId) OVER (PARITITON BY a.DeviceId, SubscriberLoginID ORDER BY CONVERT(DATETIME,GPSDateTime)) NextStatus,
a.GPSDateTime,
LEAD(GPSDateTime) OVER (PARTITION BY a.DeviceId, SubscriberLoginID ORDER BY CONVERT(DATETIME, GPSDateTime)) NextGPSDateTime,
a.LocationName,
LEAD(LocationName) OVER (PARTITION BY a.DeviceId, SubscriberLoginID ORDER BY CONVERT(DATETIME, GPSDateTime)) NextLocationName
FROM
tblGPSDataDetail a WITH(NOLOCK)
JOIN
dbo.tblDeviceMaster tdm WITH(NOLOCK) ON a.DeviceID = tdm.DeviceID
AND CityID = 3
WHERE
CONVERT(VARCHAR, CONVERT(DATETIME, GPSDateTime), 101) = CONVERT(VARCHAR(20), GETDATE() - 1, 101)
暂无答案!
目前还没有任何答案,快来回答吧!