从平均查询总计的回合

时间:2014-02-19 20:35:41

标签: php mysql sql

任何人都可以帮助我查询...在我当前的查询中,我计算出特定人的总分的平均值,并且输出就像4.232398我希望它自动舍入最终得分所以这不是十进制类型输出....任何人都可以帮助我。

我的疑问:

SELECT DISTINCT 
(SELECT SUM(t2.inttotal)
 FROM app_interview2 AS t2 
 WHERE t2.atic = t.atic)/7
 AS interview_sum,

(SELECT SUM(o2.ototal)
 FROM other_app2 AS o2 
 WHERE o2.oaic = t.atic)/7
 AS other_sum,

atid,
atic,
atname,
region,
town,
uniq_id,
position,
salary_grade,
salary
FROM app_interview2 AS t
WHERE uniq_id = '$q'
GROUP BY t.atname HAVING COUNT(DISTINCT t.atic)

2 个答案:

答案 0 :(得分:2)

SELECT ROUND(SUM(t2.inttotal), x)其中x是您需要的小数位数。

答案 1 :(得分:-1)

假设你想要结合面试金额和其他金额(你没有指定)

SELECT DISTINCT 
(SELECT SUM(t2.inttotal)
 FROM app_interview2 AS t2 
 WHERE t2.atic = t.atic)/7
 AS interview_sum,

(SELECT SUM(o2.ototal)
 FROM other_app2 AS o2 
 WHERE o2.oaic = t.atic)/7
 AS other_sum,

ROUND(SUM(interview_sum,other_sum)),

atid,
atic,
atname,
region,
town,
uniq_id,
position,
salary_grade,
salary
FROM app_interview2 AS t
WHERE uniq_id = '$q'
GROUP BY t.atname HAVING COUNT(DISTINCT t.atic)