Little more.. (PostgreSQL)
WITH latest_execution AS (
SELECT
ah.AH_CLIENT,
ah.AH_NAME,
ah.AH_OTYPE,
ah.AH_IDNR,
ah.AH_TIMESTAMP1,
ah.AH_TIMESTAMP2,
ah.AH_STATUS,
ROW_NUMBER() OVER (
PARTITION BY ah.AH_CLIENT, ah.AH_NAME
ORDER BY ah.AH_TIMESTAMP1 DESC
) AS rn
FROM AH ah
WHERE ah.AH_OTYPE = 'JOBP'
AND ah.AH_TIMESTAMP1 >= CURRENT_TIMESTAMP - INTERVAL '30 days' ---only the last 30 days of history
)
SELECT
AH_CLIENT,
AH_NAME AS workflow_name,
AH_IDNR,
AH_TIMESTAMP1 AS start_time,
AH_TIMESTAMP2 AS end_time,
AH_STATUS
FROM latest_execution
WHERE rn = 1
ORDER BY AH_CLIENT, AH_NAME;
Returns only the latest execution for each unique workflow.
Thanks,
/Kiran
Original Message:
Sent: Jul 16, 2026 09:26 AM
From: Rick Murray
Subject: SQL query to identify workflows executed in the last 30 days
Would this help
select
ah_client AS "Client",
ah_name AS "Object Name",
ah_otype as 'Jobtype',
ah_status AS "Status",
ah_idnr AS "RunID",
Ah_HOSTDST as 'Agent',
AH_TimeStamp2 as "Start Time",
AH_TimeStamp4 as "End Time"
from ah WITH(NOLOCK)
where AH_TimeStamp2 >= '2025-12-01 00:00:00.0'
and AH_TimeStamp2 <= '2025-12-31 23:59:59.9'
and ah_otype in ('JOBS','JOBP')
and ah_client = '100'
order by 1,4,2 desc;