Как бы я преобразовал все даты, которые в настоящее время YYYY-MM-DD Time, где время 00:00.
Ниже мой код, и я прикрепляю пи c
select* from(SELECT
Date,
Depot,
Vehicle,
Quantity as [Ltrs],
OdoReadingMiles,
LAG(OdoReadingMiles, 1) OVER (PARTITION BY Vehicle ORDER BY Date) AS previousmileage
,OdoReadingMiles-LAG(OdoReadingMiles, 1) OVER (PARTITION BY Vehicle ORDER BY Date) as [Miles]
,(OdoReadingMiles-LAG(OdoReadingMiles, 1) OVER (PARTITION BY Vehicle ORDER BY Date)) / (Quantity/4.544) as [MPG]
,case when (OdoReadingMiles-LAG(OdoReadingMiles, 1) OVER (PARTITION BY Vehicle ORDER BY Date)) / (Quantity/4.544) not between 2 and 10 then 1 else 0 end as [Anomaly]
FROM [Fleet].[DwhTriscanChargeouts] )as x
WHERE x.Anomaly=0
ORDER BY 2,1