You are on page 1of 2

SELECT GR.PNAME PNAME,GR.BR_CODE BR_CODE,GR.CATNAME CATNAME,GR.R_LOTNO, GR.SUPPNAME SUPPNAME,(NVL(SO.SOLD_QTY,0)*NVL(GR.SELLING_RATE,0)) SELLING_VALUE , GR.MRP MRP,NVL(GR.NET_RECV_QTY,0) NET_RECV_QTY,NVL(SO.

SOLD_QTY,0) SOLD_QTY FROM SELECT DISTINCT A.P_NAME||' ('||A.P_CODE||')' PNAME,BR_CODE, A.P_CODE P_CODE,C.CAT_NAME||' ('||C.CAT_CODE||')'CATNAME, R_LOTNO R_LOTNO,B.NAME||' ('||B.CODE||')' SUPPNAME, D.SALE_RATE SELLING_RATE,CO_BATCH_NO,D.MRP MRP, SUM(CASE WHEN RI='R' THEN NVL(D.INV_QTY,0) ELSE NVL(D.INV_QTY,0)*-1 E ND) NET_RECV_QTY, 0 SOLD_QTY,DEP_CODE,D.COMP_CODE, SUM( D.SALE_RATE*D.INV_QTY)NET_SALE_VALUE --D.NET_SALE_VALUE FROM PRODUCT_MASTER A, GLMAST B, INVKEY D, M_CATEGORY C WHERE A.P_CODE=D.P_CODE AND B.CODE=D.PARTY_CODE AND A.CAT_CODE=C.CAT_CODE AND D.DOC_TYPE IN('GR','PR') --AND D.P_CODE=15462 --and r_lotno=327 -- &P_ADD_WHERE --&P_ADD_WHERE1 AND V_DATE BETWEEN :P_START_DATE AND :P_END_DATE GROUP BY A.P_NAME,A.P_CODE,BR_CODE,C.CAT_NAME,C.CAT_CODE, B.NAME,B.CODE,D.SALE_RATE,D.MRP,R_LOTNO, DEP_CODE,D.COMP_CODE,CO_BATCH_NO (

) GR, ( SELECT DISTINCT A.P_NAME||' ('||A.P_CODE||')' PNAME,BR_CODE,A.P_CODE P_ CODE, C.CAT_NAME||' ('||C.CAT_CODE||')'CATNAME,R_LOTNO R_LOTNO, B.NAME||' ('||B.CODE||')' SUPPNAME --,D.SALE_RATE SELLING_RATE, D.MRP MRP ,0 NET_RECV_QTY,DEP_CODE,D.COMP_CODE,CO_BATCH_NO, SUM(CASE WHEN RI='I' THEN D.INV_QTY ELSE D.INV_QTY*-1 END) SOLD_QTY FROM PRODUCT_MASTER A, GLMAST B,INVKEY D, M_CATEGORY C WHERE A.P_CODE=D.P_CODE AND A.CAT_CODE=C.CAT_CODE AND B.CODE=D.SUPP_CODE AND D.DOC_TYPE IN('SO','SR') --AND D.P_CODE=15462 --and r_lotno=327 --&P_ADD_WHERE AND V_DATE BETWEEN :P_START_DATE AND :P_END_DATE GROUP BY A.P_NAME,A.P_CODE,BR_CODE,C.CAT_NAME,C.CAT_CODE, B.NAME,B.CODE --,D.SALE_RATE,D.MRP

,R_LOTNO, DEP_CODE,D.COMP_CODE,CO_BATCH_NO

) SO WHERE AND AND --AND AND --AND AND AND GR.BR_CODE=SO.BR_CODE(+) GR.P_CODE=SO.P_CODE(+) GR.P_CODE=15462 GR.R_LOTNO=327 GR.R_LOTNO=SO.R_LOTNO GR.DEP_CODE=SO.DEP_CODE(+) GR.CO_BATCH_NO=SO.CO_BATCH_NO(+) GR.COMP_CODE=SO.COMP_CODE(+)

select * from invkey where dep_code='SAL' AND P_CODE=15462 AND DOC_TYPE IN ('SO','SR')