Skip to content
Advertisement

Retrieve max date

I am trying to retrieve only the record with the max ELIGIBLE date. I have two orders in a table with the same order number. The difference in the orders is that the ELIGIBLE dates are different. I only want to retrieve the record with the latest ELIGIBLE date.

The order information in ord_order table.

ORDER NUMBER    | APPOINTMENT TYPE | ELIGIBLE
----------------+------------------+----------
264000000000382 | 109000000000001  | 11-JAN-16  
264000000000382 | 109000000000005  | 06-NOV-19  

I expect to only pull the information with the ELIGIBLE date as 06-NOV-19.

I expect to only pull the information with the ELIGIBLE date as 06-NOV-19.

Advertisement

Answer

According to your description you simply want to retrieve the row with the maximum eligible date. That is:

In your query:

With multiple orders:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement