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 |
|
wkm1925
Posting Yak Master
207 Posts |
Posted - 2008-06-08 : 23:57:51
|
Last query, mr. visakh help to produce a result as followDate_Taken | Main_ID | Daily_Rainfall-------------------------------------------5/1/2005 | 194 | 1426/1/2005 | 194 | 1557/1/2005 | 194 | 1328/1/2005 | 194 | 1995/1/2005 | 196 | 3336/1/2005 | 196 | 5447/1/2005 | 196 | 7228/1/2005 | 196 | 845......*Combination of Date_Taken and Main_ID generate unique row*Above data consist of 1 May 2005 to 1 AUG 2005 data (4 month data for each Main_ID), which is Date_Taken start from 1st day every month.*Date_Taken | Main_ID | Daily_Rainfall-------------------------------------------5/1/2005 | 194 | 142---> Mean, In May 2005 Main_ID=194 having 142 Daily_Rainfall6/1/2005 | 196 | 544---> Mean, In Jun 2005 Main_ID=196 having 544 Daily_RainfallLet's say, current month is 8I stuck to do the query to display result like as followDate_Taken | Main_ID | CurrentMonth_DR | LastMonth_DR | Last2Month_DR| Last3Month_DR--------------------------------------------------------------------------------------8/1/2005 | 194 | 199 | 132 | 155 | 1428/1/2005 | 196 | 845 | 722 | 544 | 333......*CurrentMonth_DR is 8/1/2005, LastMonth_DR is 7/1/2005, Last2Month_DR is 6/1/2005 and so on ( this can be harcoded in sql)Plz help me  |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-09 : 15:51:24
|
| Read about Cross-tab Reports in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|