Home » SQL & PL/SQL » SQL & PL/SQL » How the does MINUS work
How the does MINUS work [message #206137] Tue, 28 November 2006 22:31 Go to next message
vgs2005
Messages: 123
Registered: April 2005
Senior Member
I have table Tab1 and Tab2:
Tab1 has

col1  col2
----  ----
 A    A1 
 A    A2
 A    A3


Tab2 has:
 
col1  col2
----  ----
 D    D1 
 B    B2
 C    C3

select col1 from Tab1
minus 
select col1 from TabB

returns one row of A. Why not 3 rows of A???
If MINUS is the same as NOT EXISTS, then why do I get 3 rows of A when I have:
select col1 from Tab1
  where not exists (select 1 from Tab2
                        where Tab1.col1 = Tab2.col1)



[Updated on: Tue, 28 November 2006 22:36]

Report message to a moderator

Re: How the does MINUS work [message #206143 is a reply to message #206137] Tue, 28 November 2006 23:10 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Except UNION ALL all other set operations (UNION, MINUS and INTERSECT) will give distinct value that too in sorted order.

By
Vamsi
Re: How the does MINUS work [message #206157 is a reply to message #206143] Wed, 29 November 2006 00:13 Go to previous message
vgs2005
Messages: 123
Registered: April 2005
Senior Member
Hmm.. didn't know that. Thanks!
Previous Topic: if you Please
Next Topic: How to form this query
Goto Forum:
  


Current Time: Sun Dec 11 04:15:55 CST 2016

Total time taken to generate the page: 0.04273 seconds