I need to get the most recently updated distinct records of people.
ID Name Balance Last Update
------- ------- ------- -------
1 John 2500 2020-09-10
2 Ali 3900 2020-09-12
3 Steve 2000 2020-09-17
4 Ali 4500 2020-09-17
I need to get a list of unique Names with their most recently updated balance.
I am using Laravel and have tried the following:
DB::table('latest_balances AS s')
->orderBy('s.id', 'DESC')
->groupBy('name');
I get a list of unique names but it doesnt get the updated balance for Ali.
I need the following:
ID Name Balance Last Update
------- ------- ------- -------
1 John 2500 2020-09-10
3 Steve 2000 2020-09-17
4 Ali 4500 2020-09-17
Any help would be appreciated.