I have a query that has EXISTS query, which has PRCS_STE_CD column. QUERY
SELECT
PRCS_SNO
, YEAR
, SUBSC_CANC_YN
FROM
TB_POT_ECD_PRCS_INFO INF
WHERE
INF.SUBSC_CANC_YN = 'N'
AND EXISTS (
SELECT 'X'
FROM TB_POT_ECD_PRCS_HIST HIS
WHERE PRCS_STE_CD = 'R01'
)
Idea is to show only ones that PRCS_STE_CD = 'R01'.
But the problem is that some have 'R01' and 'R02' for PRCS_STE_CD.
(In this case, where it has both R01 and R02, I do not want to show it on the list.)
Basiacally, I want to show one that only has R01 for PRCS_STE_CD.
Oh and PRCS_STE_CD CAN NOT have only R02. It must have R01 in order to have R02.
And again, when it has both R01, R02, it should not be selected on the list.
Can anyone help editing the query?