Assuming the values are actually stored in valid column names, then the simplest way is to use union all
. However, a more performing way is unpivot or cross apply
:
select t.Engine_No, t.Date, t.Process, b.Bolt_No, b.Value1, b.Value2, b.Value3
from t cross apply
(values (Bolt_No1, Value1_1 Value1_2 Value1_3),
(Bolt_No2, Value2_1 Value2_2 Value2_3),
(Bolt_No3, Value3_1 Value3_2 Value3_3),
(Bolt_No4, Value4_1 Value4_2 Value4_3)
) b(Bolt_No, Value1 Value2 Value3);
I have no idea what SR NO
is. It is not mentioned in the data.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…