如何在in语句中使用自定义排序
create table A
(
id indentity(1,1)
num int
)
select * from A where id in(3,1,2)
问题,我希望结果是按3,1,2来进行排序显示,但是默认是根据id排序显示的,即实际显示结果是安1,2,3显示的
怎么做到我要的效果,请高手帮忙,谢谢
问题点数:20、回复次数:2Top
1 楼zjcxc(邹建)回复于 2006-05-03 13:28:52 得分 20
select * from A where id in(3,1,2)
order by charindex(','+rtrim(id)+',',',3,1,2,')
Top
2 楼guoguo19811025(蝈蝈)回复于 2006-05-04 14:29:17 得分 0
看到zjcxc(邹建) 大哥心里就有底了,呵呵!
谢谢Top




