将同一数据列中不同行的记录合并
Club the records in the column of same data in different rows
我需要将不同行中的记录连接起来。就像我的 TESTNAME 在不同的行中是相同的项目名称一样,我需要将它们组合在一起并将其显示在一行中,我使用的查询也是为了制作 pivot 请找到下面的代码
select ProjectName,
ProjectNos,
isnull([Questionnaire Submission for sripting],'') as c1,
isnull([Programing of questionnaire and/or ConJoint Design/Email Send out],'') as c2,
isnull([Quality Check (Desktop and Mobile)],'') as c3,
isnull([Questionaire link sent to client for review],'') as c4,
isnull([Hard Launch],'') as c5,
isnull([Data Collection],'') as c6,
isnull([Quality Check (Sampling)],'') as c7,
isnull([Status of sampling process sent to client],'') as c8,
isnull([Data Exported & Cleansed],'') as c9,
isnull([Coding of Open Answers],'') as c10,
isnull([Table Report],'') as c11,
isnull([PPT Report],'') as c12,
isnull([Data Analysis],'') as c13,
isnull([Raw Data Delivery to CDT],'')as c14,
isnull([Quality Check ( Table Report/Raw Data)],'')as c15,
isnull([Power Point Quality Check ],'')as c16,
isnull([Final Presentation Delivery to CDT],'')as c17,
isnull([Extra Analysis (after presentation)],'')as c18,
isnull([N-visualize report],'')as c19,
isnull([Excel Delivery],'') as c20 from tbl_ProjectDetails
PIVOT (
max(Status_Name) 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 where flag='0'
其输出如下
ProjectName ProjectNos c1 c2 c3 c4
test 123 123456 Not yet started
TESTNAME 45612 Alert
testfr 785412 Missed deadline
sdsd adsads Not Applicable
tyeuir 8948948 In progress
wwew 2324234234 Not yet started
TESTNAME 45612 Missed deadline
试试这个:
select ProjectName,
ProjectNos,
isnull([Questionnaire Submission for sripting],'') as c1,
isnull([Programing of questionnaire and/or ConJoint Design/Email Send out],'') as c2,
isnull([Quality Check (Desktop and Mobile)],'') as c3,
isnull([Questionaire link sent to client for review],'') as c4,
isnull([Hard Launch],'') as c5,
isnull([Data Collection],'') as c6,
isnull([Quality Check (Sampling)],'') as c7,
isnull([Status of sampling process sent to client],'') as c8,
isnull([Data Exported & Cleansed],'') as c9,
isnull([Coding of Open Answers],'') as c10,
isnull([Table Report],'') as c11,
isnull([PPT Report],'') as c12,
isnull([Data Analysis],'') as c13,
isnull([Raw Data Delivery to CDT],'')as c14,
isnull([Quality Check ( Table Report/Raw Data)],'')as c15,
isnull([Power Point Quality Check ],'')as c16,
isnull([Final Presentation Delivery to CDT],'')as c17,
isnull([Extra Analysis (after presentation)],'')as c18,
isnull([N-visualize report],'')as c19,
isnull([Excel Delivery],'') as c20
from (
select ProjectName,
ProjectNos,
Status_Name,
[Task_assigned]
from tbl_ProjectDetails
where flag='0') as t
PIVOT (
max(Status_Name) 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
结果
ProjectName ProjectNos c1 c2 c3 c4 ...
-------------------------------------------------------------------------------
sdsd adsads Not Applicable
test 123 123456 Not yet started
testfr 785412 Missed deadline
TESTNAME 45612 Missed deadline Alert
tyeuir 8948948 In progress
wwew 2324234234 Not yet started
我需要将不同行中的记录连接起来。就像我的 TESTNAME 在不同的行中是相同的项目名称一样,我需要将它们组合在一起并将其显示在一行中,我使用的查询也是为了制作 pivot 请找到下面的代码
select ProjectName,
ProjectNos,
isnull([Questionnaire Submission for sripting],'') as c1,
isnull([Programing of questionnaire and/or ConJoint Design/Email Send out],'') as c2,
isnull([Quality Check (Desktop and Mobile)],'') as c3,
isnull([Questionaire link sent to client for review],'') as c4,
isnull([Hard Launch],'') as c5,
isnull([Data Collection],'') as c6,
isnull([Quality Check (Sampling)],'') as c7,
isnull([Status of sampling process sent to client],'') as c8,
isnull([Data Exported & Cleansed],'') as c9,
isnull([Coding of Open Answers],'') as c10,
isnull([Table Report],'') as c11,
isnull([PPT Report],'') as c12,
isnull([Data Analysis],'') as c13,
isnull([Raw Data Delivery to CDT],'')as c14,
isnull([Quality Check ( Table Report/Raw Data)],'')as c15,
isnull([Power Point Quality Check ],'')as c16,
isnull([Final Presentation Delivery to CDT],'')as c17,
isnull([Extra Analysis (after presentation)],'')as c18,
isnull([N-visualize report],'')as c19,
isnull([Excel Delivery],'') as c20 from tbl_ProjectDetails
PIVOT (
max(Status_Name) 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 where flag='0'
其输出如下
ProjectName ProjectNos c1 c2 c3 c4
test 123 123456 Not yet started
TESTNAME 45612 Alert
testfr 785412 Missed deadline
sdsd adsads Not Applicable
tyeuir 8948948 In progress
wwew 2324234234 Not yet started
TESTNAME 45612 Missed deadline
试试这个:
select ProjectName,
ProjectNos,
isnull([Questionnaire Submission for sripting],'') as c1,
isnull([Programing of questionnaire and/or ConJoint Design/Email Send out],'') as c2,
isnull([Quality Check (Desktop and Mobile)],'') as c3,
isnull([Questionaire link sent to client for review],'') as c4,
isnull([Hard Launch],'') as c5,
isnull([Data Collection],'') as c6,
isnull([Quality Check (Sampling)],'') as c7,
isnull([Status of sampling process sent to client],'') as c8,
isnull([Data Exported & Cleansed],'') as c9,
isnull([Coding of Open Answers],'') as c10,
isnull([Table Report],'') as c11,
isnull([PPT Report],'') as c12,
isnull([Data Analysis],'') as c13,
isnull([Raw Data Delivery to CDT],'')as c14,
isnull([Quality Check ( Table Report/Raw Data)],'')as c15,
isnull([Power Point Quality Check ],'')as c16,
isnull([Final Presentation Delivery to CDT],'')as c17,
isnull([Extra Analysis (after presentation)],'')as c18,
isnull([N-visualize report],'')as c19,
isnull([Excel Delivery],'') as c20
from (
select ProjectName,
ProjectNos,
Status_Name,
[Task_assigned]
from tbl_ProjectDetails
where flag='0') as t
PIVOT (
max(Status_Name) 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
结果
ProjectName ProjectNos c1 c2 c3 c4 ...
-------------------------------------------------------------------------------
sdsd adsads Not Applicable
test 123 123456 Not yet started
testfr 785412 Missed deadline
TESTNAME 45612 Missed deadline Alert
tyeuir 8948948 In progress
wwew 2324234234 Not yet started