How can i find the greatest between three date columns using Jooq query ?

67 views
Skip to first unread message

debapri...@gmail.com

unread,
Jul 31, 2019, 3:55:12 AM7/31/19
to jOOQ User Group
Hi,

I have a table which contains three Timestamp columns. I wanted to find the latest date from the three columns.

How can i achieve that ? Any help would be greatly appreciated.

Thanks,
Deba

Table
---------------------
Col1  Timestamp
Col2  Timestamp
COl3 Timestamp


Knut Wannheden

unread,
Jul 31, 2019, 4:06:04 AM7/31/19
to jooq...@googlegroups.com
Hi,

Thank you for your message.

The standard SQL GREATEST() function should do what you are looking for. So just use DSL.greatest() as in e.g.

DSL.greatest(MY_TABLE.COL1, MY_TABLE.COL2, MY_TABLE.COL3)

Hope this helps,
Knut

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/6cee2833-3cfe-4e8e-beca-503aedd87653%40googlegroups.com.

Debapriya Patra

unread,
Jul 31, 2019, 10:55:07 AM7/31/19
to jOOQ User Group
Hi Kunt,

I am using Jooq 3.11.8 and I dont see that greatest() available in DSL for that version. Do i need to change the version ?

Can you please suggest ?

Thanks,
Deba

Knut Wannheden

unread,
Aug 2, 2019, 9:15:25 AM8/2/19
to jooq...@googlegroups.com
Hi again,

It should be there. Here is the documentation, in case there was some confusion regarding the signature: https://www.jooq.org/javadoc/3.11.8/org/jooq/impl/DSL.html#greatest-org.jooq.Field-org.jooq.Field...-

Please let me know if I misunderstood the question.

Knut

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages