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.
Author |
Topic |
Aravind N R
Starting Member
6 Posts |
Posted - 2013-12-26 : 07:11:12
|
Hi Team, How to Fix the decimal value with two values without rounding offe.g if the value is 54.778 the output should be 54.77 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-12-26 : 07:26:04
|
ROUND(9, 2, {0 | 1} ).See Books Online which parameter value {0 | 1} does truncating instead of rounding. Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
Aravind N R
Starting Member
6 Posts |
Posted - 2013-12-26 : 07:39:40
|
HiYou mean to say we can write like belowSELECT ROUND('54.778',<1 | 2>) |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-12-26 : 07:45:50
|
select ROUND(54.778, 2, 1) KH[spoiler]Time is always against us[/spoiler] |
|
|
Aravind N R
Starting Member
6 Posts |
Posted - 2013-12-26 : 07:56:40
|
Thanks, but here after decimal we will get three digit. It need to get fix with two digitE.g The output for your query will be 54.770but i need to get 54.77 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-26 : 11:10:15
|
quote: Originally posted by Aravind N R Thanks, but here after decimal we will get three digit. It need to get fix with two digitE.g The output for your query will be 54.770but i need to get 54.77
CAST it to decimal with scale value 2 thenSELECT CAST(ROUND(54.778, 2, 1) AS decimal(10,2)) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
Aravind N R
Starting Member
6 Posts |
Posted - 2013-12-26 : 12:07:10
|
Thank You, It works and you rocks !!!Thank You All for Replying. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-28 : 04:05:22
|
Welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|