I need to find out the row corresponding to the row in table2 which gives a single row output for the below query. I will be writing a JPA criteria query for this query. I am able to get the max(date) from the subquery but not the exact row (corresponding to this max value) for the table2.
SELECT table2.ER AS col_0_0_,
table1.CR AS col_1_0_
FROM table1 table1 CROSS
JOIN table2 table2
WHERE table2.date=
(SELECT max(table2i.date)
FROM table3 table3 CROSS
JOIN table2 table2i
WHERE table2i.id=table2.id
AND table2i.FC=?
AND table2i.TC=?
AND table2i.TCOB=?
AND table2i.FCOB=?
AND table2i.TC=table1.id
AND table2i.RT=?
AND table2i.RTOB=?
AND table3.id=?
AND table2i.date<=table3.CD)