I wonder if it is possible to pivot the following table:
10 A ddd
24 B fff
34 B ddd
12 A ddd
I need to pivot it like this
A B text
-- -- ----
22 34 ddd
0 24 fff
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
PIVOTfunction for this:See SQL Fiddle with Demo
If your values are known, then you can hard-code them similar to the query above. But if you have an unknown number of values, then you can use dynamic sql to create the query string. Your dynamic sql code would look like this:
See SQL Fiddle with Demo
The result of both queries is: