Having looked at the null comparisons, let’s see how they behave in
ordering and indexing. For ordering purposes, in a bow to practicality, NULLs are considered to be equal to each other in terms
of grouping, because, hey, if they were not, ordering them wouldn’t be very useful.

WITH ordertest AS (
        SELECT NULL
        UNION ALL
        SELECT 2
        UNION ALL
        SELECT 1
        UNION ALL
        SELECT NULL
)
SELECT * FROM ordertest
ORDER BY 1;
 ?column?
----------
        1
        2
   (null)
   (null)

Continue Reading »