Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 2nd, 2004, 07:13 PM
tim snl's Avatar
tim snl tim snl is offline
Code Cruncher
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Tasmania, Australia
Posts: 119 tim snl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 21 m 20 sec
Reputation Power: 8
Unhappy ORDER BY with NULL values

Hello, I hope someone can help me.

I have a column in a select query that is of type TimeStamp and the value is often NULL. I have this column in my ORDER BY clause in the query.

The problem is that I need the rows with this TimeStamp=NULL to be listed first, then the other dates. Using DESC and ASC does not change the order of NULL rows and I can't put COALESCE() in the ORDER BY CLAUSE.

How can I get this query to order NULL rows first, then valid data after that?
__________________
Beware of a programmer with a screwdriver!

Reply With Quote
  #2  
Old December 2nd, 2004, 08:13 PM
skidder skidder is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 15 skidder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to skidder
Simple :-)
Read the docs please.

Since Firebird 1.5:
1) select * from sometable order by timestampfield nulls first
2) You can have COALESCE in ORDER BY

Reply With Quote
  #3  
Old December 2nd, 2004, 08:38 PM
tim snl's Avatar
tim snl tim snl is offline
Code Cruncher
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Tasmania, Australia
Posts: 119 tim snl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 21 m 20 sec
Reputation Power: 8
Quote:
Originally Posted by skidder
Simple :-)
Read the docs please.

Thankyou - this fixes my problem.
The 1.5 release added a number of nice bits that have helped me a lot - Well done firebird

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > ORDER BY with NULL values


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway