Hi all, I need some help to build SQL Query. I have table having data like:
ID Date Value
1 12/01/2009 4
2 12/02/2009 3
3 12/03/2009 6
4 12/01/2008 2
5 12/02/2008 4
6 12/03/2008 5
Here is my query:
select ID, Date, Value from MyTable
where Date between '12/01/2009' and '12/04/2009'
and it returns the following rows:
ID Date Value
1 12/01/2009 4
2 12/02/2009 3
3 12/03/2009 6
But I need the data in the following format:
ID Date Value lastYearValueANDSameDate
1 12/01/2009 4 2
2 12/02/2009 3 4
3 12/03/2009 6 8
Here I need to get the last year value of the same date in the lastYearValueANDSameDate
column.
Thanks