在一个透视列中添加两个子列

时间:2015-01-19 10:21:01

标签: c# sql .net sql-server pivot

This is my output for current code
我已经在下面提到了代码,它根据分配的任务给出了数据透视表。我想将子列分割为头号作为开始日期广告结束日期。如何在枢轴列中添加子列

CREATE PROCEDURE sp_pivottask_datewise1
AS
SELECT ProjectName
    ,ProjectNos
    ,isnull([Questionnaire Submission for sripting], '') AS Questionnaire_Submission_for_sripting
    ,isnull([Programing of questionnaire and/or ConJoint Design/Email Send   out], '') AS Programing_of_questionnaire_and_or_ConJoint_Design_Email_Send_out
    ,isnull([Quality Check (Desktop and Mobile)], '') AS Quality_Check_Desktop_and_Mobile
    ,isnull([Questionaire link sent to client for review], '') AS Questionaire_link_sent_to_client_for_review
    ,isnull([Hard Launch], '') AS Hard_Launch
    ,isnull([Data Collection], '') AS Data_Collection
    ,isnull([Quality Check (Sampling)], '') AS Quality_Check_Sampling
    ,isnull([Status of sampling process sent to client], '') AS Status_of_sampling_process_sent_to_client
    ,isnull([Data Exported & Cleansed], '') AS Data_Exported_Cleansed
    ,isnull([Coding of Open Answers], '') AS Coding_of_Open_Answers
    ,isnull([Table Report], '') AS Table_Report
    ,isnull([PPT Report], '') AS PPT_Report
    ,isnull([Data Analysis], '') AS Data_Analysis
    ,isnull([Raw Data Delivery to CDT], '') AS Raw_Data_Delivery_to_CDT
    ,isnull([Quality Check ( Table Report/Raw Data)], '') AS Quality_Check_Table_Report_Raw_Data
    ,isnull([Power Point Quality Check ], '') AS Power_Point_Quality_Check
    ,isnull([Final Presentation Delivery to CDT], '') AS Final_Presentation_Delivery_to_CDT
    ,isnull([Extra Analysis (after presentation)], '') AS Extra_Analysis_after_presentation
    ,isnull([N-visualize report], '') AS Nvisualize_report
    ,isnull([Excel Delivery], '') AS Excel_Delivery
FROM (
    SELECT ProjectName
        ,ProjectNos
        ,convert(VARCHAR(10), Startdate, 103) AS startdate
        ,convert(VARCHAR(10), enddate, 103) AS enddate
        ,[Task_assigned]
    FROM tbl_ProjectDetails
    WHERE flag = '0'
    ) AS t
PIVOT(max(startdate) FOR [Task_assigned] IN (
            [Questionnaire Submission for sripting]
            ,[Programing of questionnaire and/or ConJoint Design/Email Send out]
            ,[Quality Check (Desktop and Mobile)]
            ,[Questionaire link sent to client for review]
            ,[Hard Launch]
            ,[Data Collection]
            ,[Quality Check (Sampling)]
            ,[Status of sampling process sent to client]
            ,[Data Exported & Cleansed ]
            ,[Coding of Open Answers]
            ,[Table Report]
            ,[PPT Report]
            ,[Data Analysis]
            ,[Raw Data Delivery to CDT]
            ,[Quality Check ( Table Report/Raw Data)]
            ,[Power Point Quality Check ]
            ,[Final Presentation Delivery to CDT]
            ,[Extra Analysis (after presentation)]
            ,[N-visualize report]
            ,[Excel Delivery]
            )) AS pivottable

This is my expected output

0 个答案:

没有答案