create or replace view vv_om110_delivery_v as
select
de.delivery_id, --调拨单号
wdd.inventory_item_id, --产品id
sum(wdd.requested_quantity) quantity, --定购数量
ic.segment3 --产品类别
from
wsh_new_deliveries de ,
wsh_delivery_details wdd,
wsh_delivery_assignments wda,
mtl_item_categories_v ic
where
wdd.delivery_detail_id = wda.delivery_detail_id
and wda.delivery_id = de.delivery_id
and ic.organization_id = wdd.organization_id
and ic.inventory_item_id = wdd.inventory_item_idgroup by de.delivery_id,wdd.inventory_item_id
order by de.delivery_id;
select
de.delivery_id, --调拨单号
wdd.inventory_item_id, --产品id
sum(wdd.requested_quantity) quantity, --定购数量
ic.segment3 --产品类别
from
wsh_new_deliveries de ,
wsh_delivery_details wdd,
wsh_delivery_assignments wda,
mtl_item_categories_v ic
where
wdd.delivery_detail_id = wda.delivery_detail_id
and wda.delivery_id = de.delivery_id
and ic.organization_id = wdd.organization_id
and ic.inventory_item_id = wdd.inventory_item_idgroup by de.delivery_id,wdd.inventory_item_id
order by de.delivery_id;
create or replace view vv_om110_delivery_v as
select
de.delivery_id, --调拨单号
wdd.inventory_item_id, --产品id
sum(wdd.requested_quantity) quantity, --定购数量
ic.segment1 --产品类别
from
wsh_new_deliveries de ,
wsh_delivery_details wdd,
wsh_delivery_assignments wda,
mtl_item_categories_v ic
where
wdd.delivery_detail_id = wda.delivery_detail_id
and wda.delivery_id = de.delivery_id
and ic.organization_id = wdd.organization_id
and ic.inventory_item_id = wdd.inventory_item_idgroup by de.delivery_id,wdd.inventory_item_id
order by de.delivery_id;
(
Select Distinct
organization_id,
inventory_item_id,
segment1 segment3
From mtl_item_categories_v
) ic
不是对它分组统计啊。对于ic的distinct,好象是多余的,因为后面的条件已作判断。
应反过来说,group by字段应在select中出现
:)