SELECT
A.DP_CODE Depot_Name,
a.empcode rmcode,
a.e_name rmname,
b.empcode fmcode,
b.e_name fmname,
b.empcodehr hrcodefe,
c.empcode mrcode,
c.e_name mrname,
c.teri_code fopin,
c.empcode mrcode,
c.empcodehr hrcodempo,
SUM (
DECODE (TO_CHAR (s.vdate, 'MON'),
'JAN', NVL (v_disptp, 0) - NVL (v_rettp, 0)
))
JAN,
SUM (
DECODE (TO_CHAR (s.vdate, 'MON'),
'FEB', NVL (v_disptp, 0) - NVL (v_rettp, 0)
))
FEB,
SUM (
DECODE (TO_CHAR (s.vdate, 'MON'),
'MAR', NVL (v_disptp, 0) - NVL (v_rettp, 0)
))
MAR,
SUM (
DECODE (TO_CHAR (s.vdate, 'MON'),
'APR', NVL (v_disptp, 0) - NVL (v_rettp, 0)
))
APR,
SUM (
DECODE (TO_CHAR (s.vdate, 'MON'),
'MAY', NVL (v_disptp, 0) - NVL (v_rettp, 0)
))
MAY
FROM emp a,
emp b,
emp c,
v$salesreport_f2 s
WHERE a.empcode = b.mgr
AND b.empcode = c.mgr
AND s.empcode = c.empcode
AND s.vdate BETWEEN :dt1 AND :dt2
AND c.empcode = NVL (:p_empcode, c.empcode)
AND s.dp_code = NVL(:dcode,s.dp_code)
GROUP BY
A.DP_CODE,
a.empcode,
a.e_name,
b.empcode,
b.e_name,
c.empcode,
c.e_name,
c.teri_code,
c.empcodehr,
b.empcodehr
ORDER BY c.e_name
No comments:
Post a Comment