在 SQLite 中获取数字的下限值? [英] Getting the floor value of a number in SQLite?

查看:26
本文介绍了在 SQLite 中获取数字的下限值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SQLite 数据库,其中包含一个表,其中包含保龄球中心的一些联盟球员的得分.我正在尝试获取每个玩家 ID 的 Score 列的平均值.问题是我只需要平均值的整个部分,而不应该四舍五入(例如:168.99 的平均值应该返回 168,而不是 169).

I have a SQLite database with a table containing the scores of some league players in a bowling center. I'm trying to get the average of the Score column for each player ID. The problem with this is I only need the whole part of the average, and it should not be rounded (example: an average of 168.99 should return 168, not 169).

当我试图在 Google 上找到类似的东西时,我只找到了 SQL Server 和其他一些的解决方案,但没有找到 SQLite,所以如果有人能帮我解决这个问题,我真的很感激!

When trying to find something like this on Google, I only found solutions for SQL Server and some others, but not SQLite, so if anyone can help me with this, I'd really appreciate it!

到目前为止,我正在使用 ROUND(AVG(s1.Score),2) 并且我正在截断使用数据库的 Java 程序中的额外部分,方法是将其转换为字符串,删除不需要的部分,然后将其转换为整数,但如果可能的话,我更愿意在 SQL 中完成所有操作.

So far, I'm using ROUND(AVG(s1.Score),2) and I'm truncating the extra part in my Java program that uses the database by converting it to a String, removing the unwanted part and then casting it to an Integer, but I'd rather do it all in SQL if possible.

推荐答案

您可以直接将其转换为整数.它会截断它,相当于floor.

You can just use cast it to an integer. It will truncate it, which is equivalent to floor.

这篇关于在 SQLite 中获取数字的下限值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆