NULL values handling in order by clause
atchaya 28 Dec 2009 06:35
Is there any option available to order the null values first or last in order by clause?
yes we can order the null values as per our requirement in order by like DESC keyword. The default value is LAST.
SELECT empname, basic FROM employee
WHERE condition
ORDER BY empname, basic NULLS FIRST
SELECT empname, basic FROM employee
WHERE condition
ORDER BY empname, basic NULLS LAST
SELECT empname, basic FROM employee
WHERE condition
ORDER BY empname NULLS FIRST, basic NULLS FIRST
SELECT empname, basic FROM employee
WHERE condition
ORDER BY empname NULLS LAST, basic NULLS LAST