Hi,
Is there any way to order by case statement below please? The output I get almost works, but the the exception of 10 (example shown below).
select
distinct
case
when t_table = '1' and t_field = '1' and t_text = 'Test1' then cast(1 as varchar(max))
when t_table = '1' and t_field = '1' and t_text = 'Test2' then cast(2 as varchar(max))
when t_table = '1' and t_field = '1' and t_text = 'Test3' then cast(3 as varchar(max))
when t_table = '1' and t_field = '1' and t_text = 'Test4' then cast(4 as varchar(max))
when t_table = '1' and t_field = '1' and t_text = 'Test5' then cast(5 as varchar(max))
when t_table = '1' and t_field = '1' and t_text = 'Test6' then cast(6 as varchar(max))
when t_table = '1' and t_field = '1' and t_text = 'Test7' then cast(7 as varchar(max))
when t_table = '1' and t_field = '1' and t_text = 'Test8' then cast(8 as varchar(max))
when t_table = '1' and t_field = '1' and t_text = 'Test9' then cast(9 as varchar(max))
when t_table = '1' and t_field = '1' and t_text = 'Test10' then cast(10 as varchar(max))
else ' ' end as 'ID'
from xxxxxxxxxxxxxxx
My output for ID is as follows
1
10
2
3
4
5
6
7
8
9
Ideally I would like it to be 1 - 10.