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 |
|
Progress2007
Starting Member
17 Posts |
Posted - 2009-03-09 : 11:31:32
|
| HelloI have a table in which there are 18 columns and there is a date Column. Now what i want that mu data should display in this formatCol1 Col2 Col3 Date1 Date2 Date3 Date 4 and so onmeans date will be in a specified range and for date there will be a duration value. i want to do this by Stored procedure.PLease help me how can i do this. |
|
|
darkdusky
Aged Yak Warrior
591 Posts |
Posted - 2009-03-09 : 12:24:52
|
| SELECT [ID] ,[q1] ,[q2] ,[q3] ,[q4],MAX(CASE WHEN [Datecol]>getdate()-7 THEN [Datecol] ELSE NULL END) AS Date1,MAX(CASE WHEN [Datecol]> getdate()-14 and [Datecol] <= getdate()-7 THEN [Datecol] ELSE NULL END) AS Date12 FROM TableName Group by [ID] ,[q1] ,[q2] ,[q3] ,[q4] |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-10 : 04:23:11
|
| is the number of date values fixed? |
 |
|
|
Progress2007
Starting Member
17 Posts |
Posted - 2009-03-10 : 04:48:01
|
| Hi vikashmy problem is that is the date selected is for one week then it should sisplay Monday to Sunday ...means 7 columnsbut is some one selectes for two week date then is should display 14 columns |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-10 : 04:50:02
|
| ok in that case what you need is to use method suggested in link before. alternatively, you can get this very easily in sql reporting tool using matrix container |
 |
|
|
Progress2007
Starting Member
17 Posts |
Posted - 2009-03-10 : 05:03:20
|
| will u pls tell me something abt sql reporting tool using matrix container |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|