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)
If you're new here, you may want to subscribe to our RSS feed or follow us on Twitter for product announcements, event information, and industry news.
Ordering and Indexing NULLs (Part 7/11)






