Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EXISTS and NOT EXIST work the opposite way with Group by

688854May 19 2011 — edited May 22 2011
Hello everyboy,,
IAm an ORacle pl/sql developer who is working on 2 databases:

I noticed that when I run a query that contains NOT exist or exists with Group by it works the opposite way, both database have same data and the values 200000000 is a non-existant value.


DATABASE 1:

Select 1 from dual where not exists (
Select max(SGBSTDN.SGBSTDN_TERM_CODE_EFF) from SGBSTDN
Where SGBSTDN.SGBSTDN_PIDM = 20000000000
Group by SGBSTDN_PIDM)

The result :

1
----------
1
1 row selected.


DATABASE 2

Select 1 from dual where not exists (
Select max(SGBSTDN.SGBSTDN_TERM_CODE_EFF) from SGBSTDN
Where SGBSTDN.SGBSTDN_PIDM = 20000000000
Group by SGBSTDN_PIDM)

result:
---------
no rows selected.

BUT when I take off NOT like:

Select 1 from dual where exists (
Select max(SGBSTDN.SGBSTDN_TERM_CODE_EFF) from SGBSTDN
Where SGBSTDN.SGBSTDN_PIDM = 20000000000
Group by SGBSTDN_PIDM)

result:


1
----------
1
1 row selected.

anybody has an explination please?????????????

Edited by: dtabed on May 19, 2011 12:49 AM

Edited by: dtabed on May 19, 2011 12:49 AM

Edited by: dtabed on May 19, 2011 12:51 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 19 2011
Added on May 19 2011
13 comments
3,020 views