我正在使用DB Browser for DBite,(版本3.10.0,Qt版本5.7.1,SQLCipher版本3.15.2),我有一个列,我想先用最高值排序。我用过:
SELECT first_name, last_name, Totalclaims
FROM workingdata
ORDER BY Totalclaims Desc;
问题是我的查询$993.00
被视为大于$9920.00
。显然,过滤器无法正确识别小数位。任何建议如何解决这个问题?
答案 0 :(得分:1)
清理Totalclaims列,这应该为您订购。
SELECT first_name, last_name, cast(replace(Totalclaims,'$', '') as SIGNED) as TotalClaims_Clean
FROM workingdata
ORDER BY Totalclaims_Clean Desc;
答案 1 :(得分:1)
– tonypdmtr wrote: Try with ORDER BY cast(replace(Totalclaims,'$','') as float) Desc;
It worked like a charm.
答案 2 :(得分:0)
如果您总是有两位小数,则先按Totalclaims
的长度排序,然后再按Totalclaims
排序。
编辑:
SELECT first_name, last_name, Totalclaims
FROM workingdata
ORDER BY length(Totalclaims) desc, Totalclaims Desc;