问:如何在Access 2013中对数字进行分组? [英] Q: How to ROUNDUP a number in Access 2013?

查看:105
本文介绍了问:如何在Access 2013中对数字进行分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Access 2013,我需要一种在SQL查询中将任何小数四舍五入到下一个整数的方法.

For Access 2013, I need a way to round up any fractional numbers to the next whole number in an SQL query.

示例:

SELECT ROUNDUP(NumberValues) FROM Table1

在上面的查询中,查询后具有1.25的行应返回2.

In the above query, a row with 1.25 should return as 2 after querying.

据我所知,Access 2013中没有用于SQL查询语句的ROUNDUP函数.

As far as I know, there's no ROUNDUP function in Access 2013 for use in a SQL query statement.

推荐答案

我从此链接中找到了等效的ROUNDUP: http://allenbrowne.com/round.html#RoundUp

I found a ROUNDUP equivalent from this link: http://allenbrowne.com/round.html#RoundUp

要向上舍入到下一个最大数字,请利用Int()将负数向下舍入的方式,如下所示: -Int(-[MyField])

To round upwards towards the next highest number, take advantage of the way Int() rounds negative numbers downwards, like this: - Int( - [MyField])

如上所示,Int(-2.1)向下舍入为-3.因此,此表达式将2.1向上舍入为3.

As shown above, Int(-2.1) rounds down to -3. Therefore this expression rounds 2.1 up to 3.

要舍入到较高的分数,请乘以-100,四舍五入,然后除以-100: Int(-100 * [MyField])/-100

To round up to the higher cent, multiply by -100, round, and divide by -100: Int(-100 * [MyField]) / -100

该语法是违反直觉的,但是它完全可以按照我的意图工作.

The syntax is counter-intuitive, but it works exactly as I intended.

这篇关于问:如何在Access 2013中对数字进行分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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