I have a jobs table that has two relevant fields
user_id. I was wondering if there's a way I can avoid joins or inline sql and just calculate both the last executed time, and the last executed time for a specific user in one simple query. I want to bee able to use MAX on everything, and a MAX on a subset of the results.
Example mock-up query. Line 3 has made-up syntax that's hopefully self-explanatory for what I want to do:
SELECT MAX(date_executed) as last_executed, MAX(date_executed, user_id = 'current-user-id') as last_executed_by_user FROM jobs; GROUP BY some_other_field