This is a smaller version of the actual query
I think this will help you get what i am trying to say.
SELECT TS.ROUTE_QTY,0, RR.INCR_STOPS_QTY
FROM
(SELECT VTSR.ROUTE_QTY, VRTS.VRPS_RUN_TS_OID_NBR
FROM VRPS_RUN_STATUS VRS, VRPS_RUN_TIME_SEGMENT VRTS,
VRPS_TIME_SEGMENT_RESULT VTSR
WHERE
VRTS.VRPS_RUN_OID_NBR = VRS.VRPS_RUN_OID_NBR
AND VRTS.VRPS_RUN_TS_OID_NBR = VTSR.VRPS_RUN_TS_OID_NBR (+)
AND VRS.DAY_PLAN_OID_NBR = :dayPlanID
) TS,
(SELECT VRTS.VRPS_RUN_TS_OID_NBR AS VRPS_RUN_TS_OID_NBR,
SUM(VRLT.INCR_STOPS_QTY) AS INCR_STOPS_QTY
FROM VRPS_RUN_STATUS VRS, VRPS_RUN_TIME_SEGMENT VRTS, VRPS_ROUTE_LEVEL_RESULT VRLT
WHERE VRTS.VRPS_RUN_OID_NBR = VRS.VRPS_RUN_OID_NBR
AND VRTS.VRPS_RUN_TS_OID_NBR = VRLT.VRPS_RUN_TS_OID_NBR
AND VRS.DAY_PLAN_OID_NBR = :dayPlanID
AND VRS.VRPS_RUN_TYPE_NBR = :executionType
GROUP BY VRTS.VRPS_RUN_TS_OID_NBR
) RR WHERE TS.VRPS_RUN_TS_OID_NBR = RR.VRPS_RUN_TS_OID_NBR (+)
regards
|