sheet:
Task: id (bigint) name (varchar). Save task details
Job: id(varchar(UUID)) task_id(bigint(class ID)), staus >(varchar( 50)),created_time (timestamp). Save task execution details
Possible values for status are FAIL/COMPLETED/INTERRUPTED
What I want to achieve is Get all latest values for each task from the job table
If there is no job in the task, the return status is null
SELECT p.id, j.status FROM tas p inner JOIN job j ON j.task_id = p.id inner JOIN job j1 ON j.task_id = j1.task_id and j.create_time > j1.create_time;
For SQL versions that support
ROW_NUMBER()
, you can do this:Otherwise, just use cte or subquery.