user3311499
user3311499

Reputation: 69

Round of total from average query

can anyone help me with my query...in my current query i calculate the average of the total score of a specific person and the out is like 4.232398 i want it to round of automatically the final score so that is not decimal type output....can anyone help me with that.

my query:

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)

Upvotes: 0

Views: 75

Answers (2)

onedevteam.com
onedevteam.com

Reputation: 4178

SELECT ROUND(SUM(t2.inttotal), x) where x is number of decimals you need.

Upvotes: 2

Dave
Dave

Reputation: 3288

Assuming you wantto combine interview_sum and other_sum (you don't specify)

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)

Upvotes: -1

Related Questions