Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear All,
I have one scenario where I need to get the latest records from the tables bases on the following columns.
first need to check for the latest records by checking the maximum of time_stamp, created_at, updated_at against each app_id. so here is the exception we do have some records with duplicated time_stamp, crated_at and updated_at so in that case, we need to take the maximum id for lasted records.
app_id | time_stamp | created_at | updated_at | id | status |
A001931002440 | 2020-05-15 12:12:05.726007 | 27-12-2019 13:46 | 27-12-2019 13:46 | 2464 | 10 |
A001931002440 | 2020-05-15 12:12:06.253003 | 11-12-2019 03:20 | 11-12-2019 03:20 | 745 | 1000 |
A001993002815 | 2020-05-15 12:12:05.725006 | 24-12-2019 11:49 | 24-12-2019 11:49 | 2025 | 10 |
A001993002815 | 2020-05-15 12:12:06.257008 | 16-12-2019 14:56 | 16-12-2019 14:56 | 1091 | 1000 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-19 13:14:03.518848 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 10 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 04:39:50.735021 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 15 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 04:39:52.687678 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 20 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 06:00:10.268946 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 30 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 06:00:10.560618 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 40 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 06:00:10.585107 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 50 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 06:00:10.750316 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 50 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 06:00:10.761145 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 60 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 06:00:10.770877 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 70 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 07:01:45.182556 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 80 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 07:04:00.363672 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 100 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 07:12:41.057400 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 1000 |
f34a051e-8c32-4ac2-8635-6dcf0af127fc | 2020-05-20 07:12:47.590471 | 19-05-2020 13:14 | 19-05-2020 13:14 | 25597 | 1000 |
the output is highlighted in bold in the above table
any help is highly applicable
Thanks,
BK