If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Penultimate date from a list

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-07-11, 04:01
Helen Pippard Helen Pippard is offline
Registered User
 
Join Date: Dec 2011
Posts: 30
Penultimate date from a list

Hello

I am very new to informix and am looking for some help

I need to know how to find the right syntex to find the penultimate date from a list

I can find the maximum date: Select MAX(datetime) maximum_date

I am thinking that i need to use the MAX function again to find the penultimate date from the same list but am unsure of the correct way to right it

Would I write it in the Select statement as something like MAX(datetime)-1?

Does anyone have any ideas?

Thanks
Helen
Reply With Quote
  #2 (permalink)  
Old 12-14-11, 20:44
domusonline domusonline is offline
Registered User
 
Join Date: Nov 2010
Posts: 12
Insteresting question...
First, do you know how to do it on any other database?
And what happens if there are two equal dates? For example:

2011-12-15 09:00:00
2011-12-15 09:00:00
2011-12-14 09:00:00

Which one should be returned? Or is this scenario impossible? If in the example above the last row would be selected, than another subquery selecting the max(date_field) ... WHERE date_field < (select max(date_field) could be used (although I fear for the performance)

Regards
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On