round
-
2012年8月20日 13:49Hi,
I am rounding numbers to 2 decimal places.
How is it possible to get the 0 at the end also?
For example, rounding 8.1243 gives 8.12
But rounding 6.4 gives 6.4 whereas I would like to see 6.40
OR if the answer is say 2 I would like to see 2.00
How is this done please?
Thanks
全部回复
-
2012年8月20日 13:52
cast to two decimal places
select cast(ROUND( 6.4,2) as decimal(3,2))
vt
Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker
- 已建议为答案 Naomi NMicrosoft Community Contributor, Moderator 2012年8月20日 13:54
- 已标记为答案 arkiboys 2012年8月20日 17:24
-
2012年8月20日 13:54
-
2012年8月20日 13:54
Try
select cast(6.4 as decimal(10,2))
-
2012年8月20日 13:55You've got some solutions, but keep in mind, that this pretends a precision of the value, which is not given due to the rounding.
- 已编辑 Stefan HoffmannMVP 2012年8月20日 14:25
-
2012年8月20日 13:58
Try
cast(round(2,2) as decimal(18,2))cast(round(8.1243,2) as decimal(18,2))
Many Thanks & Best Regards, Hua Min
- 已编辑 HuaMin ChenMicrosoft Community Contributor 2012年8月20日 14:00
-
2012年8月21日 9:15Thank you all

