aggregate-functions

Trouble converting SQL Query into JPQL (Eclipselink)

Hey guys, I have the following query and for the life of me I can't seem to translate it into JPQL. The working SQL is: select * from TB_PRINT_DETAIL y inner join (select JOB_ID,max(COPY_NUM) MAX_COPY_NUM from TB_PRINT_DETAIL group by JOB_ID ) x on y.JOB_ID = x.JOB_ID and y.COPY_NUM = x.MAX_COPY_NUM My feeble attempt at translati...