我想添加要为值设置的小数精度
例:
select 1*1.00000;
Run Code Online (Sandbox Code Playgroud)
输出: 1.0
甚至试过演员
select cast(cast(1*1.0000 as double) as decimal(5,2))
Run Code Online (Sandbox Code Playgroud)
输出: 1
我希望结果显示为1.000。蜂巢有什么办法吗?
创建一个表并对其进行测试。如果我们给出十进制函数中提到的精确精度值,它将起作用。
create table test1_decimal (b decimal (5,3));
INSERT INTO test1_Decimal values(1.000); //This will shrink it to 1 as the total digits is not five.
INSERT INTO test1_Decimal values(123.12345); //This results in NULL as it exceeds the total digits(5).
INSERT INTO test1_Decimal values(12.123); //This will give you exact result as the precision and number of digits fits. Ouputs as 12.123
Run Code Online (Sandbox Code Playgroud)
因此,如果该值与十进制函数匹配,则它将正确显示,否则它将缩小或转换为NULL。