本文介绍了如何在SQL限制中将AVG函数的小数位仅设置为2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将平均值的小数位数限制为2.
I want to limit the decimal of the average to 2..
SELECT grade.GStudNo, AVG(grade.Grade) AS Average, students.LName, students.FName, students.MName, students.Course
FROM students INNER JOIN grade ON students.StudNo = grade.GStudNo
WHERE GSem = '$sem' AND GYear = '$year'
GROUP BY grade.GStudNo
ORDER BY Average ASC LIMIT 3
推荐答案
SELECT grade.GStudNo, ROUND( AVG(grade.Grade),2 ) AS Average, students.LName, students.FName, students.MName, students.Course
FROM students INNER JOIN grade ON students.StudNo = grade.GStudNo
WHERE GSem = '$sem' AND GYear = '$year'
GROUP BY grade.GStudNo
ORDER BY Average ASC LIMIT 3
将其舍入到两个位置.
这篇关于如何在SQL限制中将AVG函数的小数位仅设置为2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!