date sort two column
date sort two column
(OP)
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
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
RE: date sort two column
SELECT NVL(AMENDED_DATE,DATE) AS NEWDATE
FROM table
ORDER BY NVL(AMENDED_DATE,DATE);
RE: date sort two column
Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting
Steam Engine enthusiasts
Steam Engine Prints