Reputation: 43
I have a SQL query like this
What I want is showing one row and adding columns dynamically
Like this:
How can I do that?
Upvotes: 0
Views: 60
Reputation: 11571
you must using pivot query.
SELECT cotation_study_uid, contation_label,[OMNIPAQUE 350*50ML] AS col1, [Crane TDM] AS col2, [Annulation produit] AS col3
(SELECT *
FROM yourtable)p
PIVOT (SUM(contation_prix) FOR cotation_label IN ('OMNIPAQUE 350*50ML', 'Crane TDM', 'Annulation produit'))
Upvotes: 1