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.

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.