The intent of the following SQL statement is to obtain "STRING" (RS.C_STR_ID,RS.C_POS_ID,RS.C_PRTY_SORT) information for a given "REGION" (RS.C_RGN_ID) and customer (AC.C_ACCT_CST ). Only strings with all known/supplied
"components" are returned from the correleated subselects.
This is a processing "HOG". I read that I could rewrite a subselect as a join query but when I try this, I get more than I expect.
Does anyone out there have any suggestions!!
SELECT RS.C_POS_ID,RS.C_STR_ID, RS.C_PRTY_SORT
FROM WGCA0P01.CA0T026_RGN_STR RS
WHERE RS.C_RGN_ID = :XXX
AND NOT EXISTS
(SELECT * FROM WGCA0P01.CA0T042_STR_CMPN SC
WHERE RS.C_STR_ID = SC.C_STR_ID
AND NOT EXISTS
(SELECT * FROM WGCA0P01.CA0T040_ACCT_CMPN AC
WHERE SC.C_CMPN_ID = AC.C_CMPN_ID
AND AC.C_ACCT_CST = :XXXXX))
ORDER BY RS.C_RGN_ID, RS.C_STR_ID, RS.C_PRTY_SORT;
Thanks
"components" are returned from the correleated subselects.
This is a processing "HOG". I read that I could rewrite a subselect as a join query but when I try this, I get more than I expect.
Does anyone out there have any suggestions!!
SELECT RS.C_POS_ID,RS.C_STR_ID, RS.C_PRTY_SORT
FROM WGCA0P01.CA0T026_RGN_STR RS
WHERE RS.C_RGN_ID = :XXX
AND NOT EXISTS
(SELECT * FROM WGCA0P01.CA0T042_STR_CMPN SC
WHERE RS.C_STR_ID = SC.C_STR_ID
AND NOT EXISTS
(SELECT * FROM WGCA0P01.CA0T040_ACCT_CMPN AC
WHERE SC.C_CMPN_ID = AC.C_CMPN_ID
AND AC.C_ACCT_CST = :XXXXX))
ORDER BY RS.C_RGN_ID, RS.C_STR_ID, RS.C_PRTY_SORT;
Thanks