我的数据MS SQL 字段是varchar(50) 类型。存的GB MB KG 例如 3.3GB 523.6MB 823.KB这种属性, 二千多条, 怎样对它进行按大小排序,sql语句怎么写?
------解决方案--------------------------------------------------------
换算后比较吧
------解决方案--------------------------------------------------------
擦 板凳 真jj麻烦
------解决方案--------------------------------------------------------
select * from tb_games order by
case when charindex('GB',filesize)>0 then convert(decimal,substring(filesize,1,charindex('GB',filesize)-1))*1024*1024
when charindex('MB',filesize)>0 then convert(decimal,substring(filesize,1,charindex('MB',filesize)-1))*1024 end desc
这么写不对 查询出这样的结果了
师傅 你也的不对 我在数据库里查询 查出这样的结果咯
3232GB
22GB
7.8GB
7.12GB
5.66GB
5.88GB
6.12GB
4.73GB
4.9GB
5.14GB
5.34GB
4.53GB
5.33GB
4.17GB
4.21GB
3.59GB
4GB
4.3GB
4.28GB
4.24GB
4.19GB
4.45GB
3.97GB
4.19GB
3.67GB
4.32GB
3232MB
3.43GB
2.95GB
3.48GB
2.69GB
3.42GB
3.36GB
3.04GB
1.67GB