所以672是在一個星期季度的量,我需要在同一天5周各方面的平均(值),在同一季度如何重寫這個SQL查詢無或「S
select value, DATEADD(MINUTE, a.QuarterNumber * 15, '2000-01-01') AS [Timestamp]
from measurements.Archive a
INNER JOIN measurements.Points p ON a.PointId = p.Id
INNER JOIN fifthcore..cm_lod_devices ld ON ld.Uuid = p.LogicalDeviceUuid
WHERE ld.Id IN (SELECT Value FROM @LodDeviceIds)
AND (
a.QuarterNumber = 510176
OR a.QuarterNumber = 510176 - 672
OR a.QuarterNumber = 510176 - (672*2)
OR a.QuarterNumber = 510176 - (672*3)
OR a.QuarterNumber = 510176 - (672*4)
OR a.QuarterNumber = 510176 - (672*5)
...
)
改用'in'。 –
類似'(a.QuarterNumber - 510176)%672 = 0'? – njzk2