Skip to content
Advertisement

SQL to pivot a field with CASE WHEN

My table has fields: Item, AttributeNo_, AttrbuteValue. Each AttributeNo_ has a matched AttributeName.

e.g.

(AttributeNo_ 1 means color, 2 means shape as AttributeName)

This is what I’m trying to achieve:

My code is:

The result is like:

How can I achieve the correct result?

Thanks in advance!

Advertisement

Answer

Use aggregation:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement