I have a table as below
Customer Product Price
C1 P1 123
C1 P2 124
C2 P1 123
C2 P2 124
I need to display the above output as below in DB2 query
Customer P1 P2
C1 123 124
C2 123 124
Please help me in achieving the above output in DB2.
Aggregate using a case
statement
select
Customer
max(case when product='P1' then Price END) P1,
max(case when product='P2' then Price END) P2
From
table
group by customer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.