SELECT l.organization_code org_code, l.organization_name org_name,
a.batch_no, SUM (NVL (b.cost_alloc, 0)) cost_alloc,
DECODE (a.batch_status,
2, 'WIP',
3, 'Completed',
4, 'Closed'
) bstatus
FROM gme_batch_header a,
gme_material_details b,
org_organization_definitions l
WHERE a.batch_id = b.batch_id
AND b.organization_id = l.organization_id
AND a.creation_date >= LAST_DAY (ADD_MONTHS (SYSDATE, -2)) + 1
AND a.batch_status IN (3, 4)
HAVING SUM (NVL (b.cost_alloc, 0)) <> 1
GROUP BY l.organization_code,
l.organization_name,
a.batch_no,
a.batch_status,
a.creation_date
ORDER BY org_code, cost_alloc DESC;
No comments:
Post a Comment
Text Message