[英]how to get accurate Decimal points in SQL Server?
這是我的查詢,我只想得到最多 2 個小數點
select (select ISNULL(sum(CONVERT(decimal(6,2),w1.Party_Weight))/CONVERT(decimal(6,2),1000),0) from weight1 as w1)+
(select ISNULL(sum(CONVERT(decimal(6,2),w2.Party_Weight))/CONVERT(decimal(6,2),1000),0) from weight2 as w2)+
(select ISNULL(sum(CONVERT(decimal(6,2),w3.Party_Weight))/CONVERT(decimal(6,2),1000),0) from weight3 as w3) as Party_Weight
這個查詢結果是 4.493000 但我只想要 4.49。
做完算術轉換!
select convert(decimal(6, 2), sum(w1.Party_Weight) / 1000.0)
from weight1 aw1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.