I have the following requirement-
1. Get the A_MINUTES column value from TableA for all rows
2. Sum the A_MINUTES.
3. Convert the summed minutes values to hours - divide by 60
4. Round off the final hours value to 2 decimal places.
This needs to be written in SQL.
Do you think this query will have any rounding errors?
SELECT ROUND ( (SUM(A_MINUTES)/60.0) , 2) FROM TABLEA
Will it have any rounding errors?
That depends on what rounding scheme you want to implement.
The SQL code you posted will accomplish your goal but the default rounding scheme in SQL is not bankers rounding like the default scheme in .NET
http://msdn.microsoft.com/en-us/library/ms175003.aspx
Here is a good brief on different rounding method implementations in SQL:
http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-rounding-methods
If you wanted to implement a banker’s rounding scheme (like the default in .NET) then there are a few options. Here is a good discussion on the topic (it is for Oracle, but should applicable)
http://www.orafaq.com/forum/t/122001/2/