select convert(numeric(8,2),round(UnTaxAmount,2))as UnTaxAmount from View_SaleVoice
select cast(UnTaxAmount as decimal(20,2)) as UnTaxAmount from View_SaleVoice第一条感觉得好一些.
本文介绍了两种从View_SaleVoice表中选取UnTaxAmount字段并进行数据类型转换的方法。第一种使用了convert函数将数值四舍五入为带有两位小数的numeric类型,第二种则通过cast函数实现相同的目标。经对比,第一种方法表现更佳。
select convert(numeric(8,2),round(UnTaxAmount,2))as UnTaxAmount from View_SaleVoice
select cast(UnTaxAmount as decimal(20,2)) as UnTaxAmount from View_SaleVoice
1006
2852