吕克让的资料库 - lhelper's repository

克己服人,礼智谦让!
Weblcome to lhelper's repository!

Monday, June 21, 2004

 

NULLS FIRST/LAST

NULLS FIRST/LAST
SELECT first_name, last_name, salary, commission_pct
FROM employees
ORDER BY commission_pct NULLS FIRST;

=====details=====
http://www.ocphk.org/newsletters/200404/oracle_faq.jsp

Question 2:
When I do a query with an order by column with NULL values, the NULLs seem to be the largest values in the column. How can I change this behaviour (to make NULL as the smallest value)?
Answer 2:
Do you know there is a new option called NULLS FIRST/LAST in the ORDER BY clause? Starting from 8.1.6, you can use this option to control the sequence of the NULL values:
SELECT first_name, last_name, salary, commission_pct
FROM employees
ORDER BY commission_pct NULLS FIRST;


Remember, this option dose not made NULLs the largest/smallest, it just made the NULLs appear on the top/bottom of your query.




Comments: Post a Comment



<< Home

Archives

June 2004   November 2005   July 2006   August 2006  

This page is powered by Blogger. Isn't yours?