Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / February 2007

Tip: Looking for answers? Try searching our database.

Order By Nulls First/Last

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Janick Bernet - 04 Feb 2007 10:11 GMT
I just stumbled upon this olap function and wondered why the "NULLS
FIRST/LAST" clause is not possible in normal order by but only using
row_number() over(). Sure, I can do a
SELECT *, row_number() over(ORDER BY col1 ASC NULLS FIRST) AS rn FROM
tab1 ORDER BY rn
to get what I want, but its awfully complicated. (Interestingly, the
optimizer rewrites above order by in an ugly ORDER BY CASE WHEN col1
is NULL THEN 0 ELSE 1, col1)

Anyone could shed any light on this? Will the functionality maybe
available in future versions of DB2 (or maybe it is already, just not
in LUW)?

Regards,
Janick
Serge Rielau - 04 Feb 2007 13:13 GMT
> I just stumbled upon this olap function and wondered why the "NULLS
> FIRST/LAST" clause is not possible in normal order by but only using
[quoted text clipped - 8 lines]
> available in future versions of DB2 (or maybe it is already, just not
> in LUW)?
I don't think it has come up as a request (at least I have never heard
of it). OLAP was added only in DB2 V7.1. Which is why it obtained more
ORDER BY options.

Cheers
Serge
Signature

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

--CELKO-- - 05 Feb 2007 16:12 GMT
>> Anyone could shed any light on this? Will the functionality maybe available in future versions of DB2 (or maybe it is already, just not in LUW)? <<

It is part of the SQL-2003 specs for OLAP extensions, so there is a
good chance you will have it soon.  The sort order of the NULLs was
originally implementation defined in the Standards.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.