Hi Klaus,
You only need to add eh.EH_Archive1 both to the SELECT (the one at the top), and to the GROUP BY (near the bottom), making it
SELECT
ah.ah_client,
TO_CHAR(ah.ah_timestamp2, 'YYYY-MM') AS yearmonth,
COUNT(ah.ah_idnr) AS usage,
ah.ah_queue AS queue,
eh.EH_Archive1
FROM AH ah
LEFT JOIN EH eh ON ah.ah_idnr = eh.eh_ah_idnr
WHERE ah.ah_hostdst IN (
SELECT oh.oh_name
FROM OH oh
INNER JOIN HOST host ON oh.oh_idnr = host.host_oh_idnr
WHERE host.host_htyp_sw NOT IN ('AVALOQAGENT', 'BS2000')
)
AND (ah.ah_status IN (1900, 1904) OR eh.eh_status IN (1900, 1904))
AND ah.ah_otype IN ('JOBS', 'JOBF')
AND ah.ah_client IN ('30')
AND ah.ah_timestamp2 BETWEEN TO_DATE('2025-07-01', 'YYYY-MM-DD') AND TO_DATE('2025-07-07', 'YYYY-MM-DD')
GROUP BY ah.ah_client, TO_CHAR(ah.ah_timestamp2, 'YYYY-MM'), ah.ah_queue, eh.EH_Archive1
ORDER BY yearmonth;
Hope this helps,
Doug
------------------------------
Thanks,
Doug
------------------------------
Original Message:
Sent: Jul 08, 2025 06:14 AM
From: Klaus Lintz
Subject: Query executions per Queue with Archive key value
Hi Team
I have a SQLI query that list the number of executions per queue for specific time frame.
I require to add the relevant Queue's Archive key 1
The archive key will contain a Cost Centre for billing purposes
Below is the Oracle query
SELECT
ah.ah_client,
TO_CHAR(ah.ah_timestamp2, 'YYYY-MM') AS yearmonth,
COUNT(ah.ah_idnr) AS usage,
ah.ah_queue AS queue
FROM AH ah
LEFT JOIN EH eh ON ah.ah_idnr = eh.eh_ah_idnr
WHERE ah.ah_hostdst IN (
SELECT oh.oh_name
FROM OH oh
INNER JOIN HOST host ON oh.oh_idnr = host.host_oh_idnr
WHERE host.host_htyp_sw NOT IN ('AVALOQAGENT', 'BS2000')
)
AND (ah.ah_status IN (1900, 1904) OR eh.eh_status IN (1900, 1904))
AND ah.ah_otype IN ('JOBS', 'JOBF')
AND ah.ah_client IN ('30')
AND ah.ah_timestamp2 BETWEEN TO_DATE('2025-07-01', 'YYYY-MM-DD') AND TO_DATE('2025-07-07', 'YYYY-MM-DD')
GROUP BY ah.ah_client, TO_CHAR(ah.ah_timestamp2, 'YYYY-MM'), ah.ah_queue
ORDER BY yearmonth;
Any help will be appreciated
Thanks
Klaus