[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1178
  • Last Modified:

Can I perform a minus operation between two result sets, like oracle's MINUS operator?

Hello

sample :

Two result sets: A and B.
I want a new set : A-B

Regards
C.M
0
cmurugavel
Asked:
cmurugavel
1 Solution
 
ornicarCommented:
You can use the NOT EXISTS statement. It will be something like:

select * from a
where not exists (select * from B where A.keycolumn = B.keycolumn)
0
 
amitpagarwalCommented:
or you could use a temp table approach ...

select * into #a from tableA

delete #a
from #a, tableB
where #a.keyCol1 = tableB.keyCol2
and #a.keyCol2 = tableB.keyCol2 .....

select * from #a

this would give u the desired result set..


cheers !!!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now