I have a header and line detail table. Such as;
Header table: TRANSACTIONS
Line detail table: TRANSACTIONS_LINE_DETAIL
In TRANSACTIONS table: SQ_TRANSACTION_ID, CH_TRANSACTION_NAME,.. columns are included.
In TRANSACTIONS_LINE_DETAIL table: SQ_TRANSACTION_LINE_DETAIL_ID, RF_TRANSACTION_ID, CH_LINE_CODE,.. columns are included.
TRANSACTIONS_LINE_DETAIL table keeps one or more detail line for each transactions which kept on TRANSACTIONS table.
So my problem is;
I wanna write a query that fetches me transactions which has X,Y and Z line codes together. (CH_LINE_CODE).
I wrote like this;
SELECT DISTINCT
TR.RF_TRANSACTION_ID
FROM
TRANSACTIONS_LINE_DETAIL TR
WHERE
TR.CH_LINE_CODE IN ('X','Y','Z')
But this code could return me transcations that hasn't got ''Y' or 'X' or 'Z'. I mean i want all line codes included in my transaciton.
I want a query that fetches me transactions that could has
X, Y, Z
or
A, B, C, X, Y, Z
or
X, Y, Z, P
but NOT
X
or
X, Y
or
Z, Y, A, B
.