HYBRD Posts · Oct 15, 2021
Returning The Greater of Two Date Fields, Where Either Could Be NULL
0Sign in to vote or save
This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.
In keeping with SQL tricks I wrote about a few days ago , here’s another technique that I’ve found useful recently. Let’s say you want to return the greater of two date fields in your result set. If you know that both fields will contain a date, then you can simply use the GREATEST function . GREATEST will return the largest of your argument. However, if either field could be NULL , then GREATEST…
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.