In the example from Rob you should change EXISTS by IN:
SELECT
T02.ITNBR, T02.STID, T02.ITRV, T02.ITDSC,
T02.UNMSR, T02.QCTYP, T02.QCDAY, T02.INTYP, T02.BLCF, T02.ALLOC
FROM WHDTA/SHRITMS T01,
JOIN AMFLIB1/ITMRVA T02 ON T01.ITNBR = T02.ITNBR
WHERE STID = 'H1P' and t02.itnbr not IN
(select itnbr from itemhist)
ORDER BY T02.ITNBR ASC, T02.ITRV ASC
Or maybe:
SELECT
T02.ITNBR, T02.STID, T02.ITRV, T02.ITDSC,
T02.UNMSR, T02.QCTYP, T02.QCDAY, T02.INTYP, T02.BLCF, T02.ALLOC
FROM WHDTA/SHRITMS T01,
JOIN AMFLIB1/ITMRVA T02 ON T01.ITNBR = T02.ITNBR
WHERE STID = 'H1P' and t02.itnbr not exists
(select * from itemhist T03 WHERE TO3.itnbr = TO1.itnbr)
ORDER BY T02.ITNBR ASC, T02.ITRV ASC
Instead, you will reach better performance with:
SELECT
T02.ITNBR, T02.STID, T02.ITRV, T02.ITDSC,
T02.UNMSR, T02.QCTYP, T02.QCDAY, T02.INTYP, T02.BLCF, T02.ALLOC
FROM WHDTA/SHRITMS T01,
JOIN AMFLIB1/ITMRVA T02 ON T01.ITNBR = T02.ITNBR
LEFT EXCEPTION JOIN ITEMHIST TO3 ON TO3.ITNBR = TO1.ITNBR
WHERE STID = 'H1P'
ORDER BY T02.ITNBR ASC, T02.ITRV ASC
Saludos,
---------------------------
Santiago Martí
Dusen, S.A.
---------------------------
Thanks Rob for the tip and the help on the code.
I am trying it but my SQL Interactive Session does not like the keyword
EXISTS ...
PETER VIDAL
MAPICS IT TECHNICAL SUPPORT TEAM / SR SYSTEM ANALYST
10540 Ridge Rd., Suite 203, New Port Richey, FL 34654-5111
Tel:727-849-9999, x2414 /// Fax:727-815-3120
WWW.PALL.COM
"Do not turn back when you are just at the goal."
Publilius Syrus (~100 BC), Maxims
--------------------------------------------------------------------------------
Attention:
This communication may contain information that is confidential,
privileged and/or exempt from disclosure under applicable law.
If you are not the intended recipient, please notify the sender
immediately and delete the original, all attachments, and all
copies of this communication.
--------------------------------------------------------------------------------
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.