June 11, 2012 at 12:41 pm
This is my current query for one pivot column
SELECT *
FROM (SELECT a.Rpt, a.C, a.[D], a.F, m.[Z], a.X,a.Y
FROM [dbo]. a INNER JOIN
[dbo].[t_Month] m ON m.ReportDate = a.ReportDate)
m PIVOT (MAX(X) FOR [Z] IN ([5/20/2012], [5/21/2012], [5/22/2012], [5/23/2012])) p
But I also need to pivot column Y under the same dates as mentioned above and the Column X ,Column Y should be side by side .
Your help is highly appreciated
June 12, 2012 at 1:18 am
Welcome To SSC.
You need to provide DDL of the tables, some sample Data and the Expected Result Set so that people can have a look at what you are looking at and provide you with a solution.
Please check out the link in my Signature and post the DDL, Sample Data and Expected Result Set accordingly.
June 12, 2012 at 9:08 am
These are the tables
CREATE TABLE [dbo].[q_Agent](
[Function] [nvarchar](255) NULL,
[Center] [nvarchar](255) NULL,
[Agent] [nvarchar](255) NULL,
[X] [float] NULL,
[Y] [float] NULL,
[INT_EXT] [nvarchar](255) NULL ,
[ReportDate] [date] NOT NULL
CREATE TABLE [dbo].[t_Month](
[Month] [datetime] NULL,
[Daily] [datetime] NULL,
[ReportDate] [date] NOT NULL
I have attached the file with the data and the current output and the output I am looking for.
June 13, 2012 at 10:22 pm
Did you checkout the link in my signature??....If not then please check it out to see how to post Sample Data.
It's good that you have provided DDL of the tables. But, no one would be willing to download the attachment that you added(you know the reason why).
It would be better if you post the Sample Data as shown in the link in my Signature. If you think thats too hard then you can visit the following link:
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply