You can use conditional aggregation as follows:
Select orderid, dn,
Max(case when atrributecode = 'contractId' then attributevalue end) as contractId,
Max(case when atrributecode = 'activationDateInherited' then attributevalue end) as activationDateInherited,
Max(case when atrributecode = 'contractExpiryDate' then attributevalue end) as contractExpiryDate,
Itemcode
From t
Group by orderid, dn, itemcode
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…