我有以下查询,其中我根据“必填”字段将一列分成不同的列。
SELECT
Station,
Line,
[Tag Reference],
FTN,
IIF(Required = "TF", Required, "") AS [TF Required],
IIF(Required = "TF", [Date Checked], "") AS [TF Date],
IIF(Required = "TF", [User Checked], "") AS [TF User],
IIF(Required = "ML", Required, "") AS [ML Required],
IIF(Required = "ML", [Date Checked], "") AS [ML Date],
IIF(Required = "ML", [User Checked], "") AS [ML User],
Format
FROM [Tag Information]
ORDER BY
Station,
Line,
[Tag Reference]
我得到的项目是每条记录都是自己的行,但想将记录组合在一起。
IE。我得到这张表,其中行被拆分,但我想查看按标签引用分组的值。(如第二张表)
Station Line Tag Reference FTN TF Required TF Date TF User ML Required ML Date ML User Format
Clearbrook 1 SCADA[30].0 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].0 TF
Clearbrook 1 SCADA[30].1 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].1 TF
Clearbrook 1 SCADA[30].10 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].2 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].4 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].4 TF 7/12/2006 WPB
Clearbrook 1 SCADA[30].5 TF 7/12/2006 WPB
Clearbrook 1 SCADA[30].5 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].6 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].8 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].8 TF 7/12/2006 WPB
Clearbrook 1 SCADA[30].9 TF 7/12/2006 WPB
Clearbrook 1 SCADA[30].9 ML 7/12/2006 WPB
我想看看这张表:
Station Line Tag Reference FTN TF Required TF Date TF User ML Required ML Date ML User Format
Clearbrook 1 SCADA[30].0 TF ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].1 TF ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].10 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].2 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].4 TF 7/12/2006 WPB ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].5 TF 7/12/2006 WPB ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].6 ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].8 TF 7/12/2006 WPB ML 7/12/2006 WPB
Clearbrook 1 SCADA[30].9 TF 7/12/2006 WPB ML 7/12/2006 WPB
任何帮助都会很棒。我很茫然。