Hi,
I need to order a cursor so the result is the same as in a sorted listbox (which can be sorted many different ways).
The solution I found online was to use a CASE statement with ORDER BY. Such as
select * from table
order by (
case id
when 3 then 0
when 1 then 1
when 4 then 2
when 2 then 3
end
)
But this simple example doesn't work (the list contains only one item)
select * from thetable where id in (1) order by case id when 1 then 0 end
What is the correct way to create an arbitrary sort order?