请帮我搞定。
输入
Part_Number,Part_Type,Description_1,Value1, Description_2,Value2,Description_3 Value3
EDG38305,Gauge, Compatibility,CTS, Location,Dashboard,Head Light,DISC
我需要这样的输出。
输出
Part_Number,Part_Type,Description_1,Value1, Description_2,Value2,Description_3 Value3
EDG38305,Gauge, '','', '','',Head Light,DISC
仅包含DISC的值列,其中包含相应描述,如果值3为DISC那么输出显示说明3和值3以及剩余电量剩余空白
谢谢大家
答案 0 :(得分:0)
您可以使用以下查询
SELECT Part_Number,Part_Type,
CASE WHEN Value1 = 'DISC' THEN Description_1 ELSE '' END AS Description_1,
CASE WHEN Value1 = 'DISC' THEN Value1 ELSE '' END AS Value1,
CASE WHEN Value2 = 'DISC' THEN Description_2 ELSE '' END AS Description_2,
CASE WHEN Value2 = 'DISC' THEN Value2 ELSE '' END AS Value2,
CASE WHEN Value3 = 'DISC' THEN Description_3 ELSE '' END AS Description_3,
CASE WHEN Value3 = 'DISC' THEN Value3 ELSE '' END AS Value3
您必须根据要检查的所需静态值数来更改IN子句