Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Round the result

Author  Topic 

jasmine123
Starting Member

2 Posts

Posted - 2009-05-10 : 12:30:48
Hi,
I need to get the result after calculation in the sql query rounded to the nearest integer,ie, if its 14.56, then result to be as 15.00 with two decimals.
Select cast(A+B+C as decimal(15,2))AS Result from tableName doesn't round the whole number part.

Thanks in advance...

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-10 : 12:34:23
You can use CEILING function to round results up to nearest integer value.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-05-11 : 01:17:59
Select round(cast(A+B+C as decimal(15,2)),0) AS Result from tableName

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jasmine123
Starting Member

2 Posts

Posted - 2009-05-11 : 10:47:17
Thanks for the information
Go to Top of Page
   

- Advertisement -