请教一个select语句

来源:百度知道 编辑:UC知道 时间:2024/05/14 03:53:22
数据库中存的这个字段有三位小数,我只想要取出两位,用SELECT语句怎么写?

select cast('YourField' as numeric(12,2)) from YourTable

SELECT CAST(2544.2644 as numeric(10,2))

用函数 CAST(数值 as numeric(n,s)),其中n表示有效数字位数,s表示小数位数

select convert(decimal(18,2),sum(field)) from table