sqlite除法返回整数值
sqlite> select totalUsers/totalBids from
(select (select count(*) from Bids) as totalBids ,
(select count(*) from Users) as totalUsers) A;
1
我们可以转换结果以获得除法结果的真实价值吗?
sqlite除法返回整数值
sqlite> select totalUsers/totalBids from
(select (select count(*) from Bids) as totalBids ,
(select count(*) from Users) as totalUsers) A;
1
我们可以转换结果以获得除法结果的真实价值吗?
Answers:
在Sqlite中,一个整数除以另一个整数将始终舍入为最接近的整数。
因此,如果将枚举器转换为浮点数:
SELECT CAST(field1 AS FLOAT) / field2
select cast ( ( select 1 ) as real );