I\'ve looked for a while and I cannot find the answer to this question (maybe I\'m not searching the correct terms or something). Basically, I have a database that has any n
Here is an idea using correlated subqueries:
with bydays as ()
select bd.*,
(select sum(NumMeasured) from (select top 100 * from bydays bd2 where bd2.date <= bd.date order by date desc) t
) as Measured100,
(select sum(NumPassingd) from (select top 100 * from bydays bd2 where bd2.date <= bd.date order by date desc) t
) as Measured100
from bydays