[help]selecting max(update_time) of a series of results.
I'm querying a log table (that logs excel macro uses) which contains data like the following:
macro_name | user_name | branch | update_time
I'm trying to return a list of all the distinct macro_names that a branch has run, and only select the newest update_time of each macro_name
Getting a list of all macros a branch has run is simple:
select * from macro_log_table
where branch = <branch>
But I get results like this:
macro_1 | user1 | <branch> | 2020-01-06 09:19:08
macro_1 | user2 | <branch> | 2020-02-16 09:19:08
macro_1 | user3 | <branch> | 2020-01-26 09:19:08
macro_2 | user1 | <branch> | 2020-03-01 09:19:08
macro_2 | user1 | <branch> | 2020-02-26 09:19:08
macro_2 | user4 | <branch> | 2020-01-15 09:19:08
macro_3 | user5 | <branch> | 2020-03-12 09:19:08
macro_3 | user4 | <branch> | 2020-02-12 09:19:08
macro_1 | user6 | <branch> | 2020-01-10 09:19:08
What I'd like is:
macro_1 | user2 | <branch> | 2020-02-16 09:19:08
macro_2 | user1 | <branch> | 2020-03-01 09:19:08
macro_3 | user5 | <branch> | 2020-03-12 09:19:08
I'm probably missing something simple, but grouping by update_time doesn't guarantee the newest time
Posted Mar 20, 2020, 2:32 AM UTC · edited
[deleted]