Reputation: 1325
we just started our studying on SQL and I seem to have a slight problem with one exercise.
I would need to round the result of
SELECT AVG(points) AS Average FROM table;
I was trying to do it with subquery but I just did not hit the correct one even tough similar subqueries with only select seem to work well.
Any help?
Upvotes: 1
Views: 146
Reputation: 4892
Use the ROUND()
function.
SELECT ROUND(AVG(POINTS), 1) AS Average FROM table;
Upvotes: 0
Reputation: 905
Select Round(Avg(Points),2) as Average from table
Reference: http://msdn.microsoft.com/en-us/library/ms175003.aspx Does this help ?
Upvotes: 0
Reputation: 37233
try this
SELECT ROUND(AVG(POINTS), 3) AS Average FROM your_table;
^^--if you want round by two decimals then use 2 and so on
Upvotes: 0