sql保留两位小数cast
时间: 2023-12-12 12:01:56 浏览: 155
要SQL中保留两位小数并使用cast函数,可以使用以下语法:
```
SELECT CAST(number AS decimal(10,2))
FROM tablename;
```
在这个例子中,"number"是你要保留两位小数的字段名,"tablename"是你要查询的表名。
使用CAST函数将number字段转换为decimal类型,并使用decimal(10,2)指定保留两位有效数字。这样就可以在查询结果中保留两位小数。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [SQL 保留两位小数的实现方式](https://blog.csdn.net/m0_58680865/article/details/117933894)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [Sql 保留两位小数](https://blog.csdn.net/qq_43649223/article/details/124883136)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文