Monday 7 July 2014

SQL for Formula List

SQL For Uploaded Formula


SELECT ffm.formula_no, ffm.formula_desc1 formula_name,
DECODE (fmd.line_type, 1, 'Product', 'Ingredient') TYPE,
msi.segment1 icode, ood.organization_code org, fmd.qty,
fmd.detail_uom, DECODE (ffm.formula_status, 700, 'Active', 'New') status
FROM apps.fm_matl_dtl fmd, apps.fm_form_mst ffm, apps.mtl_system_items_b msi,
apps.org_organization_definitions ood
WHERE fmd.formula_id = ffm.formula_id
AND (fmd.inventory_item_id = msi.inventory_item_id(+)
AND fmd.organization_id = msi.organization_id(+))
AND fmd.organization_id = ood.organization_id
AND fmd.line_type=1 ORDER BY formula_no,
DECODE (fmd.line_type, 1, 'Product', 'Ingredient') DESC;