This was one of those things where I've just gone 'I wonder if this works..' and strangely enough it DID!
Situation was something like the following (okay – something is a very broad term, because it wasn't really like this at all) –
I have a document management system – and each document has a
document_createdDate and a
document_releaseDate – however if the user chose to release a document 'Now' the
document_releaseDate would be set to
So when I went to order a document list by
document_releaseDate, obviously that would be rather hard, as values could be
NULL in a date list.
So I figured – why not sort such that, if is
NULL, then sort by the
document_createdDate – that would provide a able solution to my sorting issue.
Then I discovered I could put
CASE statements into my
ORDER BY clause – and that made things real easy – e.g.
WHEN document_releaseDate IS NULL then
And presto – a conditional sort! Of course there are other ways to solve the same problem, but I thought that was nifty.
This was done a Oracle 9i database.