I have a equipment table and the equipment has a coding for each place / location or custody it has had during its life. I need to select the latest (newest) row for each piece of equipment by getting the newest from_date and to_date field combination.
The following is an example. I know how to get MAX date for one column but not with two columns (from and to DATES). Any suggestions or examples would be great. I know with other db languages there are GREATEST functions. Not able yet to find the options.
ID | NAME | FROM_DATE | TO_DATE |
21 | TNK101 | 01/01/2013 | 03/15/2013 |
21 | TNK101 | 03/16/2013 | 05/05/2013 |
21 | TNK101 | 05/06/2013 | 12/31/2075 |
34 | BNK201 | 03/15/2013 | 12/31/2075 |
104 | CRL309 | 01/01/2013 | 03/15/2013 |
104 | CRL309 | 03/01/2013 | 05/25/2013 |
104 | CRL309 | 05/26/2013 | 11/15/2013 |
104 | CRL309 | 11/16/2013 | 12/31/2075 |