0

e06bda938bd3817cedb4e3d69265b84ce06bda938bd3817cedb4e3d69265b84ce06bda938bd3817cedb4e3d69265b84c Hi,

I have a below table of Content

CUSTOMER ID QUESTIONS ANSWER
1 FirstName John
1 LastName William
1 Country India
1 Zip Code 60000
2 FirstName xxxx
2 LastName yyyy
2 Country US
2 Zip Code 123456
3 OrgName ABC Pvt Ltd
3 Country UK
3 Zip Code 987654

I want to convert this row of data into single row group by Customer ID as mentioned below,

Customer Id First Name Last Name Org Name Country Zip Code
1 John William India 60000
2 xxxx yyyy US 123456
3 ABC Pvt Ltd UK 987654

kinldy let me know how can I achieve this.

Thanks in Advance.

Edited by visweswaran28

2
Contributors
1
Reply
11
Views
3 Years
Discussion Span
Last Post by urtrivedi
0
select customer_id 
, max(case when questions='FirstName' then answer else null end) FirstName
, max(case when questions='LastName' then answer else null end) LastName
, max(case when questions='OrgName' then answer else null end) OrgName
, max(case when questions='Country' then answer else null end) Country 
, max(case when questions='ZipCode' then answer else null end) ZipCode
from tablename group by customer_id

Edited by urtrivedi

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.