我正在尝试从单个表中选择特定的数据集,然后将它们分组显示在单个字段下。然而,这会为每个 case 语句创建一行。
理想情况下,我希望每个报价单都有一行,每个字段都针对它。
有没有人知道我如何改进我到目前为止所做的事情?
select
KeyField as Quote,
CASE WHEN FieldName = 'QTY001' THEN AlphaValue ELSE null END as [QTY],
CASE WHEN FieldName = 'CON002' THEN AlphaValue ELSE null END as [Conductors],
CASE WHEN FieldName = 'COP001' THEN AlphaValue ELSE null END as [Copper Size],
CASE WHEN FieldName = 'COR001' THEN AlphaValue ELSE null END as [Core Length],
CASE WHEN FieldName = 'COR002' THEN AlphaValue ELSE null END as [Core Inside],
CASE WHEN FieldName = 'END001' THEN AlphaValue ELSE null END as [End Winding],
CASE WHEN FieldName = 'KV_001' THEN AlphaValue ELSE null END as [KV],
CASE WHEN FieldName = 'KW_001' THEN AlphaValue ELSE null END as [KW],
CASE WHEN FieldName = 'NAM001' THEN AlphaValue ELSE null END as [OEM],
CASE WHEN FieldName = 'SLO001' THEN AlphaValue ELSE null END as [Slots],
CASE WHEN FieldName = 'SPE001' THEN AlphaValue ELSE null END as [Speed],
CASE WHEN FieldName = 'TUR001' THEN AlphaValue ELSE null END as [Turns],
CASE WHEN FieldName = 'TYP001' THEN AlphaValue ELSE null END as [Type/Description]
from
AdmFormData
where
FormType = 'QOT'