I have a sql coding question:
I have tableX with a HistoryDate column and an AmountX column. I need to subtract the AmountX column for the latest HistoryDate from the AmountX column for the HistoryDate from seven days prior.
create table TableX (HistoryDate datetime, ItemAmount float)
There is no index (yet), it's just a small table for testing.
There is a row for each day of the year, and a corresponding item amount. I have to compute the difference of ItemAmount for the row with max(HistoryDate) and the row from 7 days prior, which would be max(HistoryDate)-7 days prior.