I need list with Columns as defined below.
Agent Name | Job_Name | Client_id | Last Run Timestamp |
---|---|---|---|
Agent-1 | Job 11 | 10 | 08.06.2022 00:30:32 |
Agent-1 | Job 12 | 10 | 04.06.2022 00:31:02 |
Agent-1 | Job 21 | 10 | 08.06.2022 00:30:32 |
Agent-1 | Job 31 | 10 | 07.06.2022 00:31:02 |
Agent-1 | Job 32 | 10 | 05.06.2022 00:31:02 |
Multiple Jobs will be running multiple times in a day or month in an agent.
I seek to get the list with only the latest (top 1 from timestamp desc) run with timestamp for all jobs on the agent.
However, I'm getting millions of rows with duplicate of jobs from same server.
select Agent_Name, Job_Name, Client_id, Last_Run_Timestamp
from table1
join table2 on table.idnr = table1.idnr
where client_id = 10
and exists (select job_name from listofjobs)
order by Agent_Name, timestamp desc