android - Sqlite 求和结果不正确

标签 android sql sqlite sum

我尝试通过 sqlite 计算一些结果。我的查询是 SELECT SUM(value) FROM Transaction。我注意到奇怪的行为。当结果 < 6 个字符是可以的,当结果 > 6 个字符时 sqlite 舍入结果。例如,如果结果为 12345678,则 sqlite 返回 1.23456e+07。谁能解释一下?

我使用 ormlite 在 android 上使用 sqlite。该值为 BIG_DECIMAL。 Ormlite 将其存储为 VARCHAR。

最佳答案

这不是不正确的结果,而是在 scientific E notation 中格式化的结果.

假设您的代码中的值为 double,则行为为 documented in Double.toString(double) .

关于android - Sqlite 求和结果不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24036284/

相关文章:

sql - 如何在logstash中将数据库版本保存为sql_last_version变量

sql - 计数值表的出现

android - Android 中的水平可扩展 ListView

android - gcloud Firebase Android 测试 : Unable to access the test environment catalog: ResponseError 403: Not authorized for project

java - fragment 内的 getIntent()

iphone - 将 map 坐标(lan,& long)存储在 sqlite 数据库中

sqlite - 如何使用Azure移动服务正确同步Xamarin iOS Sqlite

android ORMLite 在数据库创建时填充表

sql - 仅在三个表中连接一行

SQL Server 2016 源代码管理