I have two tables Emp & Emp_Details
Emp -> EmpId, EmpName
Emp_Details -> EmpDetailId, Domain, Year, Date_of_record
Each employee has many domains, where their perfomance is measured, and it can be measured more than once a year.
So emp1 can have more than one recodes in Emp_Details for Domain1 for year 2015.
Now I want to fetch latest records per Domain per year for an employee.
Currently I'm fetching using two nested FOR loops in Java, i.e. one FOR loop for each factor and another inner FOR loop for each year fetching latest Date_of_record.
How should I optimize it? I'm using PL/SQL.