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