Home » SQL & PL/SQL » SQL & PL/SQL » Distinct - Why NULL values are treated as single value ?
Distinct - Why NULL values are treated as single value ? [message #248250] Thu, 28 June 2007 07:52 Go to next message
prabhuapps
Messages: 79
Registered: June 2005
Location: Bangalore
Member
Hi,

SQL> select * from emp order by empno;

    EMPNO ENAME         DEPTNO
--------- ---------- ---------
        1 HNP               10
        2 ABC               20
        3 XYZ               30
        4 PRABHU
        5 VIVEK

SQL> select distinct deptno from emp;

   DEPTNO
---------

       30
       20
       10


One article says, One NULL is NOT equal to another NULL.

If that is the case, why distinct retrieving only one NULL value.

Regards,
Prabhu
Re: Distinct - Why NULL values are treated as single value ? [message #248255 is a reply to message #248250] Thu, 28 June 2007 08:06 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Because they are not different either?
Re: Distinct - Why NULL values are treated as single value ? [message #248257 is a reply to message #248250] Thu, 28 June 2007 08:10 Go to previous message
Michel Cadot
Messages: 64102
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Oracle does not check equality between NULL it just groups the rows that have no value.

Regards
Michel
Previous Topic: simple sql
Next Topic: Selecting Ranges
Goto Forum:
  


Current Time: Fri Dec 02 14:12:13 CST 2016

Total time taken to generate the page: 0.08182 seconds