sql server想要小数点后向下取整怎么搞

sql server想要小数点后向下取整怎么搞_第1张图片

 select FORMAT(3.169, 'N2') as '四舍五入1',
 CAST(3.169 AS decimal(9,2)) as '四舍五入2',
 ROUND(3.169, 2) as '四舍五入3',
 CAST(FLOOR(3.169 * 100) / 100 AS decimal(9,2)) as '向下取整1',
 FLOOR(3.169 * 100) / 100 as '向下取整2',
 ceiling(3.169 * 100) / 100 as '向上取整——参考向下取整'

其中: select TRUNC('3.159',10,2)   这个是我问gpt回答的,我还以为是别的数据库的内置函数,我搜了一下sql server百度里面也有。但是我用不了,版本问题?

你可能感兴趣的:(数据库,sql,sqlserver)