I am Aggregating the data on ‘INTERIM_AUTO’ table on the basis of Unit ID, Line ID, CURR_DATE i.e.
SELECT INTERIM_AUTO_ID,
UNIT_ID,
PROD_LINE_ID,
CURR_DATE,
BAL_AMOUNT,
V_SOURCE_CODE,
CURR_ID,
CREATED_BY,
UPDATED_DATETIME
FROM INTERIM_AUTO
WHERE CURR_DATE = to_date(V_DATE, 'MM/DD/YYYY')
GROUP BY UNIT_ID,
PROD_LINE_ID,
CURR_DATE
And then if we get multiple entries for the above combination then I have to do the summation of BAL_Amount and consider the single entry for the above combination with this calculated Amount. How do I achieve this?
It sounds like you want to calculate the sum of the BAL_AMOUNT column. You can do this with the
SUMfunction.If you use
SUMon your BAL_AMOUNT column, you will have to add all your other columns into theGROUP BY:Or remove the columns you don’t need: