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 |
|
Scott
Posting Yak Master
145 Posts |
Posted - 2002-02-22 : 03:35:23
|
| I want to order by a column that can only have the following values:Estimate, Request, Reccomend, Approvedin that order.Is a case statement the most efficient way to do this or is there a quicker way?SELECT Budget, Phase, case when Phase = 'Estimate' then 1 when Phase = 'Request' then 2 when Phase = 'Reccomend' then 3 when Phase = 'Approved' then 4end as PhaseIDFROM EvalBudget ORDER BY phaseID, FinYear; |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-02-22 : 06:54:11
|
| That's probably the best way. You could also put the CASE statement in the ORDER BY clause by itself, if you don't want to have the PhaseID in your column output:SELECT Budget, Phase FROM EvalBudget ORDER BY case when Phase = 'Estimate' then 1when Phase = 'Request' then 2when Phase = 'Reccomend' then 3when Phase = 'Approved' then 4end, FinYear; |
 |
|
|
|
|
|