I know that this subject is already well exposed here but I believe that I've a specific case and I didn't find any solutions so far.
I have the following result set:
Tp_Parameter Value Order_Id
------------ ----- --------
Colour Black 3824
Size S 3824
Qty 2 3824
ItemId 101 3824
Colour White 3824
Size M 3824
Qty 1 3824
ItemId 102 3824
Colour Red 3824
Size L 3824
Qty 4 3824
ItemId 105 3824
And I'm looking for a result set like this:
Order_Id ItemId Colour Size Qty
-------- ------ ------ ---- ---
3824 101 Black S 2
3824 102 White M 1
3824 105 Red L 4
I've tried with pivot, but I couldn't deal with the fact that it had to use aggregated functions, which one results in a one line result set (just the MAX or MIN etc etc)
Could you help me with that?
ItemIdandColour. The colourBlackcould belong to any of those ItemIds. It looks like you're simply depending on the order they're currently displayed up there, but that won't work in a SQL table where the default ordering will be based upon clustered indexes.idon the rows?