Date | Temperature | OldTemperature | NewTemperature |
12-May-12 | 35 | Some Value before 12 May | 35 |
13-May-12 | 40 | 35 | 40 |
14-May-12 | 10 | 40 | 10 |
15-May-12 | 0 | 10 | 0 |
17-May-12 | 17 | 0 | 17 |
18-May-12 | 0 | 17 | 0 |
20-May-12 | 25 | 0 | 25 |
21-May-12 | 34 | 25 | 34 |
Hi Please see above Data. We will be capturing daily temperatures, some days there are chances of not capturing due to some reasons. Ex: 16-May-2012,19-May-2012 is not captured in above table.
Now I have to generate report with date as parameter to it. Report should have Columns like ReportDate,OldTemperature,NewTemperature. Let me explain how values will be populated.
If report parameter's date has data captures on particular date we should populate NewTemperature=IFEXISTS(ReportParameter's temperature),OldTemperature ReportParameter's IFEXISTS(previous date temperature) if there is no data capture on report parameter date then IFEXISTS(previous day's temperature) will be NewTemperature, IFEXISTS(the previous temperature of NewTemperature) will be OldTemperature.
Can You Please guide me how to get these data using sql server 2005
Thanks & Regards, Sunil A.