Skip to content
Advertisement

How do a pivot on sql server on one column but renamed dynamics column

I’ve a table of prices With Reference, Price Category (Ex professional/Customer…) , the weight and the price Each article have X lines for same Reference, Price Category depend of weight I Want a return with Reference, Price Category, Price1,Price2… I try to adapt codes I’ve found but I’ve a problem to linked weight and named columns PRIX1,PRIX2…

I don’t want have each weight in separate column but only classify on Prix1, prix2…

Advertisement

Answer

Finally… Force to try I create a view on my table With row number based on my group by

AND In a stored procedure

Now I just need to group by and on each added column put Max(Prix1) as prix1 ,…always using a variable string

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