Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: ArunnHi,
I want to group by the data based on the fields and get the values of non-key fields based on the latest date.
Input :
AcctNo DeptNo Amt Balance Bal_Date
100 Mech 1000 800 01-Nov-2018
100 Mech 2000 500 02-Nov-2018
100 Mech 1000 800 03-Nov-2018
200 Civil 5000 500 01-Nov-2018
200 Civil 1000 800 02-Nov-2018
200 Civil 3000 300 03-Nov-2018
300 IT 7000 1000 01-Nov-2018
300 IT 8000 3000 02-Nov-2018
I want to group by based on the fields AcctNo, DeptNo and sum of Amt field and latest values of Balance & Bal_Date.
Expected Output :
AcctNo DeptNo SUM(Amt) Balance Bal_Date
100 Mech 4000 800 03-Nov-2018
200 Civil 9000 300 03-Nov-2018
300 IT 15000 3000 02-Nov-2018