我希望我能弄清楚这一点。我需要生成一个平均称为 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`;
有什么建议么?
SELECT
`TC Code`,
round(AVG(ALW_AMT),0) AS AVG_AMT
FROM
OFFICE_Claims_Physicians
GROUP BY
`TC Code`
ORDER BY
`TC Code`;
您想使用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`;
使用圆函数
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`;