Jay
Jay

Reputation: 65

Combining Query Result sets in Oracle sql

How to combine multiple query result sets in oracle SQL

The sample Query is

Select * from table where table.id in

(

   (
    select table.id 
    from table 
    where cond 1 

    intersect

    select table.id 
    from table 
    where cond 2   
   ) 

union
(

    select table.id 
    from table 
    where cond 3   

    intersect

    select table.id 
    from table 
    where cond 4

)
)

I want to get the intersect result first and then union should be applied how to combine two result sets like these ?

Upvotes: 0

Views: 112

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269873

How about just doing this?

Select *
from table
where ((cond 1) and (cond 2)) or
      ((cond 3) and (cond 4));

Upvotes: 1

Related Questions