jooq finding lastest value in table

Solutions on MaxInterview for jooq finding lastest value in table by the best coders in the world

showing results for - "jooq finding lastest value in table"
Kinsey
03 Apr 2020
1// Assuming these static imports
2import static org.jooq.impl.DSL.*;
3import static com.example.generated.Tables.*;
4
5Student t = STUDENT.as("t");
6Field<Date> maxDate = max(STUDENT.EVENT_DATE).as("MaxDate");
7Table<?> tm = table(select(STUDENT.ID, maxDate)
8                   .from(STUDENT)
9                   .groupBy(STUDENT.ID)).as("tm");
10
11ctx.select()
12   .from(t)
13   .join(tm)
14   .on(t.ID.eq(tm.field(STUDENT.ID)))
15   .and(t.EVENT_DATE.eq(tm.field(maxDate)))
16   .fetch();
17
similar questions
queries leading to this page
jooq finding lastest value in table