Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
reddy_vam
Starting Member
43 Posts |
Posted - 2012-11-06 : 13:22:15
|
I have a table called Test and it contains 3 fields called id, Current date and description.I wanted to write a query such that it list out the id, currentdate, description and also (Currentdate-1 year) and description part related to the 1 year back date.Can someone help me with this query.Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-11-06 : 13:43:00
|
[code]SELECT t1.*,t2.currentdate as prevyrdate,t2.description as prevyrdescriptionFROM table t1LEFT JOIN table t2ON t2.currentdate = DATEADD(yy,-1,t1.currentdate)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|