当前位置: 代码迷 >> Sql Server >> 在sql中,怎么将查询到的字段进行四舍五入后显示出来
  详细解决方案

在sql中,怎么将查询到的字段进行四舍五入后显示出来

热度:31   发布时间:2016-04-27 14:22:18.0
在sql中,如何将查询到的字段进行四舍五入后显示出来
在sql中,如何将查询到的字段进行四舍五入后显示出来
比如:
select Price from F --Price是nvarchar(50)类型的 Price的值和123243.2324类似
求解:如何通过四舍五入后保留两位小数???

------解决方案--------------------
SQL code
declare @F table (Price numeric(10,4))insert into @Fselect 123243.2324 union allselect 3243.2354 union allselect 22.2344select CAST(Price AS DECIMAL(18,2)) AS Price from @F/*Price---------------------------------------123243.233243.2422.23*/
  相关解决方案