Click here to Skip to main content
16,015,991 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Date          data     prevdaydata           
15/2/2015       20                     0
16/2/2015       50                     20
17/2/2015        90                    50
18/2/2015      120                     90
19/2/2015        140                   120
Posted
Updated 16-Jun-15 2:42am
v5

1 solution

If i understand you correctly...

Try this:
SQL
SELECT t1.Date, t1.data, COALESCE(t2.Data,0) As prevdata
FROM TableName AS t1 LEFT JOIN (
    SELECT DateAdd(dd, 1, Date) As [Date], data
    FROM TableName
    )AS t2 ON t1.Date = t2.Date
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900