May 28, 2008 at 9:26 am
I need to sort all records with an expired date at the bottom.
i.e if table_column_ExpDate<getdate() ... (set variable?)
order by variable, something else, somthing else.
What's the best way to do this sort of thing?
Thanks
May 28, 2008 at 11:44 am
Do you mean something like this:
SELECT...
FROM...
WHERE...
ORDER BY CASE WHEN @MyVariable = 52 THEN Column1
WHEN @MyVariable = 42 THEN Column2
ELSE Column3
END
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
May 28, 2008 at 12:33 pm
I think this is more of what I was looking for, but thanks.
ORDER BY case when datediff(day,p.Prodclosedate,getdate()) > 0 then 1 ELSE 2 end
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply