2

我希望我能弄清楚这一点。我需要生成一个平均称为 AVG_AMT(整数)并且没有小数的表。它可以舍入或截断。这张桌子真的没关系。

这是我试图写的:

SELECT `TC Code`, AVG(ALW_AMT) as int(8,0) AS AVG_AMT
FROM OFFICE_Claims_Physicians
GROUP BY `TC Code`
ORDER BY `TC Code`;

有什么建议么?

4

3 回答 3

6
SELECT 
    `TC Code`, 
    round(AVG(ALW_AMT),0) AS AVG_AMT
FROM 
    OFFICE_Claims_Physicians
GROUP BY 
    `TC Code`
ORDER BY 
    `TC Code`;
于 2012-06-17T01:36:16.843 回答
1

您想使用ROUND()函数

SELECT `TC Code`, ROUND(AVG(ALW_AMT)) as int(8,0) AS AVG_AMT
FROM OFFICE_Claims_Physicians
GROUP BY `TC Code`
ORDER BY `TC Code`;
于 2012-06-17T01:35:41.897 回答
0

使用圆函数

SELECT `TC Code`, ROUND(AVG(ALW_AMT)) as int(8,0) AS AVG_AMT
FROM OFFICE_Claims_Physicians
GROUP BY `TC Code`
ORDER BY `TC Code`;

如果您只想要一位或两位小数

 SELECT `TC Code`, ROUND(AVG(ALW_AMT),1/2) as int(8,0) AS AVG_AMT
 FROM OFFICE_Claims_Physicians
 GROUP BY `TC Code`
 ORDER BY `TC Code`;
于 2014-06-07T11:37:49.060 回答