MS SQL + Query pulling data by week
Posted on 2013-01-24
I have a table with a date, customerid, and then dollar amount. the date represents the start of the week.
what i am trying to do is pull a list of all the customerids with a dollar value in a week, which is the easy part.
i am then trying to pull 7 previous weeks worth of data for each customerid that is in the initial query, so the final query would show all the customerids from the first week and then 7 previous weeks of data, the other part is if the customerid doesnt have a value in a week previous then a null value would be shown.
is this possible and if so how?