I have a fairly simple query that executes correctly in DB2 but I'm having troubles figuring out how to group results to give me 2 columns with values that replace the colum of 2 different rows. In other words, for each product I get 2 rows (one with active price, one with temporary price) but I want to make it so that I get one distinct product row with a column for each price type and the price
The query:
select distinct grouping, body, fabric,color,thread,detail, category,p.priceType,p.price
from ordering offs
inner join pricing p
on offs.body = p.bodyp
where priceType in ('Active','Temporary')
and offs.category in ('A','B','C');
What I'm getting:
grouping | body | fabric | color | thread | detail | category | p.priceType | price
-----------------------------------------------------------------------------------------------------
ABC 123 1234 Blue 1.1 1 TEXTILE Active 594.00
ABC 123 1234 Blue 1.1 1 TEXTILE Temporary 560.00
ABC 123 1234 Red 0.5 0 TEXTILE Active 584.00
ABC 123 1234 Red 0.5 0 TEXTILE Temporary 550.00
ABC 123 1234 Grn 3.3 12 TEXTILE Active 594.00
ABC 123 1234 Grn 3.3 12 TEXTILE Temporary 560.00
What I want to get:
grouping | body | fabric | color | thread | detail | category | ActivePrice | TemporaryPrice
------------------------------------------------------------------------------------------------------------
ABC 123 1234 Blue 1.1 1 TEXTILE 594.00 560.00
ABC 123 1234 Red 0.5 0 TEXTILE 584.00 550.00
ABC 123 1234 Grn 3.3 12 TEXTILE 594.00 560.00