I am trying to convert the lag function to use in access-sql, which simply doesn't have the function. So I have a table A with columns Type (a,b or c),Decider (1 or 2), Dates and Values..I would like to create another column which simply shifts the values down one date, with the first value then being null.
I tried to use this thread below, but I guess I'm doing something wrong still:
Calculating difference in column value from one row to the next
My attempt was
select type, dates, values,
(select top 1 test.values
from test as m
where m.dates < test.dates
group by test.type, test.values, test.dates
order by test.values,test.dates desc
) as lag
from test
group by test.type, test.dates,test.values
order by test.dates



select top 1 test.valuesshould that no be:select top 1 m.values, and also most other references totest.*(except for the one in the WHERE-clause)