Hello - I am stumped on how to return a field value from the previous record.
I have a really simple dataset - just a Billing Date and Sales values.
BillingDate Sales
1/1/2018 1
1/2/2018 2
1/3/2018 3
1/4/2018 4
1/5/2018 5
1/6/2018 6
1/7/2018 7
1/8/2018 8
1/9/2018 9
1/10/2018 10
Here is the SQL that I have:
When I run this, it is not returning the expected value, just nulls for the PriorDaySales.Code:SELECT *, (SELECT Top 1 Sales from tblSales as P WHERE P.BillingDate<BillingDate) as PriorDaySales FROM tblSales
Any ideas why? What am I doing wrong?