Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Hurkle
Starting Member
5 Posts |
Posted - 2001-12-14 : 12:56:39
|
| Greets, all.I'm trying to build an 'order by' clause.I'm sure this is a simple operation, but I can't figure it out.right now, I've got ORDER BY fldDate and that returns the records in the order I want, if the date field is not null. If a given date field is not null, I want it to be first. If it's null, I want it to be after the records with dates.Any ideas? Thanks in advance..Hurkle |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2001-12-14 : 13:33:43
|
| SQL Server doesn't require the ORDER BY expressions to occur as an output column, so you can do this:ORDER BY CASE WHEN fldDate IS NULL THEN 1 ELSE 0 END, fldDateEdited by - Arnold Fribble on 12/14/2001 13:37:04 |
 |
|
|
Hurkle
Starting Member
5 Posts |
Posted - 2001-12-14 : 14:34:45
|
| Excellent, that did the trick. Thanks very much, Mr. Fribble, you're a godsend.Hurkle |
 |
|
|
|
|
|