fikir
Programmer
- Jun 25, 2007
- 86
I have this table and trying to order by
Code:
declare @tbl table (col varchar(100))
insert into @tbl
select '((ABC)+F)'
union all select '123'
union all select 'ABC+F'
union all select 'DEF'
union all select 'XYZ'
I wrote this query
select *
from @tbl
order by case when left(col, 2) = '((' then 'ABC+F1' end
to sort the data
I wanted it to be
col
123
ABC+F
((ABC)+F)
DEF
XYZ
but it is giving me the following resultset
col
123
ABC+F
DEF
XYZ
((ABC)+F)
[\code]
how can I change my code to get the right order
Thanks,