Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SDETERS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

date sort two column

Status
Not open for further replies.

NTrade

Computer
Jan 10, 2007
7
Have an sql puzzle that is so classical it could be text book.

Column1 is Date
Column2 is Amended Date

There is always an entry in Column1 - there is occasionally an entry in Column2.

My query needs to return the records in chronological order - and the Amended Date is to be used when it exists in terms of that record's location in the chronological order. (One can presume that the Amended Date is always correct and doesn't need to be compared with its own original date.)

Am going to nick away at some sql statements and would welcome input from anyone out there that likes an sql puzzle...thanks in advance ntc
 
Replies continue below

Recommended for you

I think this would about do it...

SELECT NVL(AMENDED_DATE,DATE) AS NEWDATE
FROM table
ORDER BY NVL(AMENDED_DATE,DATE);
 
I don't have an answer at present, but I believe that NVL is an Oracle-only construct

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting
Steam Engine enthusiasts
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor