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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 order the output using a list ...

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-01-11 : 08:20:00
Edwin writes "Hello,

I've a sorting order question. there is a list of questions that can be ordered by the question administrator, and the sequesnce of the question is fi 25,10,3,4,24. The users of the question list have to get the questions is that defined order...



select question_id from T_BFS_questions
where question_id in (25,10,3,4,24)

result is 3,4,10,24,25

I would like to get it as defined (25,10,3,4,24)
order by will not make this possible.


ps the questions are inserterd as 1,2,3,4,5,6,7,8,9,etc...

Anyone ??????

Greetings,
Edwin"

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-11 : 08:31:41
[code]select question_id from T_BFS_questions
where question_id in (25,10,3,4,24)
order by charindex(cast(question_id as varchar(2)), '25,10,3,4,24')[/code]

-----------------
'KH'

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
Go to Top of Page
   

- Advertisement -