Home » SQL & PL/SQL » SQL & PL/SQL » Order by Dates - Blanks coming first
Order by Dates - Blanks coming first [message #392791] Thu, 19 March 2009 05:23 Go to next message
velnias2008
Messages: 3
Registered: March 2009
Junior Member
Hey All,

I 2 columns Date Added and Date Updated

I am trying to sort my table by date updated.

Not all records will have date updated date, when I am doing the sort the problem is the records with a blank are coming in first then my date updated ones sorted come through.

How can I get the sort to work with most upto date dateupdated records first then the records with no date updated which are then sorted as normal by dateAdded.

Steven
Re: Order by Dates - Blanks coming first [message #392795 is a reply to message #392791] Thu, 19 March 2009 05:25 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
ORDER BY

There's all sorts of things in the documentation, if you read it.
Re: Order by Dates - Blanks coming first [message #392799 is a reply to message #392795] Thu, 19 March 2009 05:32 Go to previous messageGo to next message
velnias2008
Messages: 3
Registered: March 2009
Junior Member
Hey Thanks for the document, I spend a good bit of time already trying google for examples like this but couldnt find much.

Has anyone ever ran into the same problem ?
Re: Order by Dates - Blanks coming first [message #392804 is a reply to message #392799] Thu, 19 March 2009 05:37 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I've run inti similar problems - the NULLS FIRST and NULLS LAST options are exactly what you're looking for.
Re: Order by Dates - Blanks coming first [message #392807 is a reply to message #392791] Thu, 19 March 2009 05:46 Go to previous messageGo to next message
velnias2008
Messages: 3
Registered: March 2009
Junior Member
Ye worked nicely thanks...

One thing I noticed though is that it sorts by dateUpdated fine but if there is a new record added which doesnt have a dateupdated date yet it doesnt go to the top of page but the first one below the last date updated even though that date is higher
Re: Order by Dates - Blanks coming first [message #392814 is a reply to message #392791] Thu, 19 March 2009 05:57 Go to previous messageGo to next message
cookiemonster
Messages: 12412
Registered: September 2008
Location: Rainy Manchester
Senior Member
post code and sample output
Re: Order by Dates - Blanks coming first [message #392819 is a reply to message #392807] Thu, 19 March 2009 06:25 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
velnias2008 wrote on Thu, 19 March 2009 11:46
Ye worked nicely thanks...

One thing I noticed though is that it sorts by dateUpdated fine but if there is a new record added which doesnt have a dateupdated date yet it doesnt go to the top of page but the first one below the last date updated even though that date is higher

Higher than what? You said the dateipdated is empty..
Previous Topic: using nested tables with CAST as normal table (merged 3)
Next Topic: Looking for API to change Saloes Person Info. of a customer
Goto Forum:
  


Current Time: Wed Dec 07 08:27:19 CST 2016

Total time taken to generate the page: 0.09409 seconds