select * from 表 order by case when 列 like '*' then cast(substring(列,2,8000) as int) else cast(列 as int) end
解决方案 »
- 存储过程中使用临时表无法再查询分析器中生成预计执行计划
- 关于xp_cmdshell的再次提问
- 关于查询的问题
- 建立触发器时,SQL6.5中不能用AFTER语句怎么办
- SQL和ASP集合的数据库写入问题,在线等。
- 求一条ms sql语句,去掉重复
- 高分请教数据库还原问题!!!!急!急!急!急!急!急!
- SQL语句高手过来领分:如何用case语句来完成此项查询(只1个表)?有兴趣的也可以进来试试!
- 初来砸道!如何将图片写入image列中?举个例子?
- WINNT 下的MySQL有多大,从那里可以得到。
- where 和 join 的效率哪个高?有没有什么好的性能测试方法或工具?
- 我如何知道是谁动了我的数据
order by
case when col like '*%' then cast(substring(col,2,4000) as int)-10000000
else cast(col as int) end
create table #t(a nvarchar(100))
insert #t
select '*2'
union select '*10'
union select '*20'
union select '*100'
union select '2'
union select '3'
union select '10'
union select '20'
union select '100'
go
select * from #t
go
select * from #t
order by
case when a like '*%' then cast(substring(a,2,4000) as int)
-10000000 --你自己根据情况定
else cast(a as int) enddrop table #t