我试图找到float
的百分比变化,但是查询返回0.00
SELECT CAST(((SELECT 115301-(SELECT 114256))/(SELECT 114256))*100 AS DECIMAL(18,2))
在这里我想念什么吗?我应该在哪里编辑SQL?
答案 0 :(得分:1)
尝试以下操作即可
SELECT CAST(CAST((115301-114256) AS FLOAT)/114256*100 AS DECIMAL(18,2))
答案 1 :(得分:0)
尝试一下:
SELECT CAST(((SELECT 115301.00- (SELECT 114256.00))/(SELECT 114256.00))*100 AS DECIMAL(18,2))
或将数字强制转换为浮点数或十进制
SELECT CAST(((SELECT cast(115301 AS DECIMAL(18,2)) - (SELECT cast(114256 AS DECIMAL(18,2))))/(SELECT cast(114256 AS DECIMAL(18,2))))*100 AS DECIMAL(18,2))