Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I order rowset in this statement?

Status
Not open for further replies.

redapple

Programmer
May 7, 2001
16
US
In the statement below:
select * from Books where (isbn IN (5, 1, 9))

The numbers in the IN clause are in random order, but that's the order I hope the resultsets return: 5,1,9, instead of 1,5,9. But how should I phrase the Order By clause?

Thanks.
 
Hi,

Try this query

select *, CASE isbn When 5 THEN 1
When 1 THEN 2
When 9 THEN 3
END orderby
from Books where (isbn IN (5, 1, 9))
Order by orderby

Sunil
 
Thanks so much Sunil!

It worked very well in QA. However I am using this SQL statement in an ASP application. ADO componet doesn't recognize this query and generates an error message when it is processed.

How can I get away from this?
 
Sunil,
My mistake, it was a syntax error. The query statement worked well now.

Thanks so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top