SELECT *
FROM (SELECT a.store_id, a.NAME STORE, a.description store_description,
b.content_type, cz.NAME content_zone_name, cz.TYPE zone_type,
categories.category_name,
lookupvalues.meaning AS category_type, cz.zone_id,
categories.rt_category_id,
cattl.category_name AS child_category,
mc.segment1 inv_cat_segment1,
mc.description inventory_category,
mct.category_id inv_category_id, msi.segment1 item_name,
msi.description item_description
FROM icx_cat_shop_stores_vl a,
icx_cat_store_contents b,
icx_cat_content_zones_vl cz,
icx_cat_zone_secure_attributes ca,
icx_cat_categories_tl categories,
fnd_lookup_values lookupvalues,
icx_por_category_order_map cm,
icx_cat_browse_trees catbr,
icx_cat_categories_tl cattl,
mtl_categories_tl mct,
mtl_categories_kfv mck,
mtl_categories mc,
mtl_item_categories mic,
mtl_system_items_b msi
WHERE a.store_id = b.store_id
AND b.content_id = cz.zone_id
AND cz.zone_id = ca.zone_id
AND ca.ip_category_id = categories.rt_category_id
AND categories.LANGUAGE = USERENV ('LANG')
AND lookupvalues.LANGUAGE = categories.LANGUAGE
AND lookupvalues.lookup_type = 'ICX_CAT_TYPE_POPLIST_VALUES'
AND lookupvalues.lookup_code = categories.TYPE
AND cm.rt_category_id(+) = cattl.rt_category_id
AND categories.rt_category_id = catbr.parent_category_id
AND cattl.rt_category_id = catbr.child_category_id
AND cattl.LANGUAGE = USERENV ('LANG')
AND cm.external_source_key = mck.category_id(+)
AND mct.category_id(+) = mck.category_id
AND mct.category_id = mc.category_id(+)
AND msi.inventory_item_id(+) = mic.inventory_item_id
AND mic.organization_id = msi.organization_id(+)
AND mic.category_id(+) = mc.category_id
AND nvl(msi.organization_id, 84) = 84
UNION ALL
SELECT a.store_id, a.NAME STORE, a.description store_description,
b.content_type, cz.NAME content_zone_name, cz.TYPE zone_type,
categories.category_name,
lookupvalues.meaning AS category_type, cz.zone_id,
categories.rt_category_id, NULL category_name,
mc.segment1 inv_cat_segment1,
mc.description inventory_category,
mct.category_id inv_category_id, msi.segment1 item_name,
msi.description item_description
FROM icx_cat_shop_stores_vl a,
icx_cat_store_contents b,
icx_cat_content_zones_vl cz,
icx_cat_zone_secure_attributes ca,
icx_cat_categories_tl categories,
fnd_lookup_values lookupvalues,
icx_por_category_order_map cm,
mtl_categories_tl mct,
mtl_categories_kfv mck,
mtl_categories mc,
mtl_item_categories mic,
mtl_system_items_b msi
WHERE a.store_id = b.store_id
AND b.content_id = cz.zone_id
AND cz.zone_id = ca.zone_id
AND ca.ip_category_id = categories.rt_category_id
AND categories.LANGUAGE = USERENV ('LANG')
AND lookupvalues.LANGUAGE = categories.LANGUAGE
AND lookupvalues.lookup_type = 'ICX_CAT_TYPE_POPLIST_VALUES'
AND lookupvalues.lookup_code = categories.TYPE
AND cm.rt_category_id = categories.rt_category_id
AND cm.external_source_key = mck.category_id(+)
AND mct.category_id(+) = mck.category_id
AND mct.category_id = mc.category_id(+)
-- AND mc.segment1 IS NOT NULL
-- and mc.STRUCTURE_ID = 201
AND msi.inventory_item_id(+) = mic.inventory_item_id
AND mic.organization_id = msi.organization_id(+)
AND mic.category_id(+) = mc.category_id
AND NVL (msi.organization_id, 84) = 84
)
where STORE = 'XXXX';
No comments:
Post a Comment