Search code examples
sqloracle-databaseoracle8i

Eliminate Records Without Combination


I have the following data in TEMP_DATA table

enter image description here

From these records, I would like to get only those records which are having CAT_NO 36 and 39 combination of records, ideally my expected results are as follows

enter image description here

How can I do this?


Solution

  • I don't have an Oracle8 instance to test but this should work:

    select * from temp_data where prod_no in ( 
        select prod_no from temp_data where cat_no = 39 and prod_no in (
           select prod_no from temp_data where cat_no = 36 ) ) ;