0

Possible Duplicate:
Accuracy in rounding numbers

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 the following query will have any rounding errors?

SELECT ROUND ( (SUM(A_MINUTES)/60.0) , 2) FROM TABLEA
Community
  • 1
  • 1
user656523
  • 3,171
  • 3
  • 22
  • 19

1 Answers1

0

If point 3.Sum the hours values to be considered you are missing one SUM function.

SELECT ROUND ( SUM(SUM(A_MINUTES)/60.0) , 2) FROM TABLEA
ray
  • 457
  • 3
  • 9
  • Actually, its just that I need to get the hours rounded off to 2 places. So, whether I (sum minutes and divide by 60) OR (convert to hours and then sum it) - doesn't make a difference. :) I can make the edits to my post. – user656523 May 02 '12 at 15:02