oracle - fetching multiple data with sql query -


i have header , line detail table. such as;

header table: transactions line detail table: transactions_line_detail

in transactions table: sq_transaction_id, ch_transaction_name,.. columns included.

in transactions_line_detail table: sq_transaction_line_detail_id, rf_transaction_id, ch_line_code,.. columns included.

transactions_line_detail table keeps 1 or more detail line each transactions kept on transactions table.

so problem is;

i wanna write query fetches me transactions has x,y , z line codes together. (ch_line_code).

i wrote this;

select distinct     tr.rf_transaction_id    transactions_line_detail tr    tr.ch_line_code in ('x','y','z') 

but code return me transcations hasn't got ''y' or 'x' or 'z'. mean want line codes included in transaciton.

i want query fetches me transactions 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

.

you may find 1 useful. here sql fiddle.

select rf_transaction_id   transactions_line_detail  ch_line_code in ('x', 'y', 'z')  group rf_transaction_id having count(1) = 3 

Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -