Answered by:
need to convert data in multiple rows with same ID into 1 row with multiple columns

-
Can somebody help me on below scenario
I am hoping to run a procedure that pulls data organized as follows:
Email | Preference
email1 | PreferenceXYZ
email1 | PreferenceABCAnd render it in a table like the following
Email | Preference1 | Preference2
email1 | PreferenceXYZ | PreferenceABC
Question
Answers
-
Hi,
I think PIVOT may help using MAX function for the aggregation.
I hope this is helpful.
Please Mark it as Answered if it answered your question
OR mark it as Helpful if it help you to solve your problem
Elmozamil Elamir Hamid
MCSE Data Platform
MCITP: SQL Server 2008 Administration/Development
MCSA SQL Server 2012
MCTS: SQL Server Administration/Development
MyBlog
- Marked as answer by SRK24 Wednesday, July 09, 2014 4:02 PM
All replies
-
Could you post sample data (DDL DML) and expected result?
Satheesh
My Blog | How to ask questions in technical forum
-
Hi,
I think PIVOT may help using MAX function for the aggregation.
I hope this is helpful.
Please Mark it as Answered if it answered your question
OR mark it as Helpful if it help you to solve your problem
Elmozamil Elamir Hamid
MCSE Data Platform
MCITP: SQL Server 2008 Administration/Development
MCSA SQL Server 2012
MCTS: SQL Server Administration/Development
MyBlog
- Marked as answer by SRK24 Wednesday, July 09, 2014 4:02 PM
-
Use Pivot or Case statement to get the desired result.
In case in preference column the values are identified and fixed you can use either Static Pivot or Case. But in case the of unknown values, the most appropriate way is to create dynamic Pivot.
- Proposed as answer by Gopal Krishna Ranjan Wednesday, July 09, 2014 7:31 AM
-