Helpful Information
 
 
Category: Other Databases
sql function min() problem

hi guys.
I have a problem with function min(). it rounds -incorrectly- the values i enter. I have a table "enroll" that has student id's (sid )
course id's (cid) and
student grades(grade)
I want to find the cid with the lowest avarage

i am using msaccess to execute this code

/////////////////////////////

SELECT z.cid
FROM (SELECT enroll.cid as cid, Avg(enroll.grade) AS Avg
FROM enroll
GROUP BY enroll.cid) AS z
WHERE z.Avg = (SELECT MIN(t.Avg)
FROM (SELECT Avg(enroll.grade) AS Avg
FROM enroll
GROUP BY enroll.cid) as t);
/////////////////////////////

SELECT Avg(enroll.grade) AS Avg
FROM enroll
GROUP BY enroll.cid) as t

part gives correctly cid's and avg's. I have the lowest avg as 2.66666667
When i put the avg column in min() function i get 2.66 so my comparison to
2.6666667 returns false. Why does min get only two steps from decimal part?










privacy (GDPR)