query [message #414248] |
Tue, 21 July 2009 03:28  |
ora_2007
Messages: 430 Registered: July 2007 Location: Mumbai
|
Senior Member |
|
|
select sku,location,sum(part_qty) from Demand_Daily_History
where sku = '10001'
group by sku,location
SKU Location Qty
10001 CARSON 1
10001 VA 5
select sku, case location when 'CARSON' then sum(part_qty) end,
case location when 'VA' then sum(part_qty) end
from Demand_Daily_History
where sku = '10001'
group by sku,location
output:
SKU CARSON VA
10001 1 NULL
10001 NULL 5
Required
SKU carson VA
10001 1 5
What logic i need to write to get required output.
|
|
|
Re: query [message #414251 is a reply to message #414248] |
Tue, 21 July 2009 03:50  |
 |
vamsi kasina
Messages: 2112 Registered: October 2003 Location: Cincinnati, OH
|
Senior Member |
|
|
Don't group by location.
Use sum(decode(location ,'CARSON',part_qty)) and sum(decode(location ,'VA',part_qty)).
By
Vamsi
|
|
|