用户登录
用户注册

分享至

T-SQL 平均值四舍五入到最接近的整数

  • 作者: 段友482234
  • 来源: 51数据库
  • 2022-10-20

问题描述

我不确定以前是否有人问过这个问题,但是如何将平均值四舍五入到 T-SQL 中最接近的整数?

I'm not sure if this has been asked before, but how do I get the average rounded to the closest integer in T-SQL?

推荐答案

这对它有用:

CONVERT(int,ROUND(AVG(CAST(COLUMN-NAME AS DECIMAL)) ,0))

难道没有更短的方法吗?

Isn't there a shorter way of doing it though?

软件
前端设计
程序设计
Java相关