1樓:匿名使用者
可以在建來
表的時候限定自小數點的長度,例如decimal(5,2),後面的2就是2位的意思。
如果表已經建好,可以在查詢語句中用函式 round(x,2) 轉換,x為欄位,後面的數字為長度,你要幾位就填幾。
sql做查詢的時候,怎麼把decimal型別的資料保留兩位小數、?
2樓:素顏以對
sql查詢抄把decimal型別資料
留兩位小數法:
select convert(decimal(38, 2),vehicle_mode) from vehicles
decimal在襲sql server裡是精確值型別,精度38;在c#裡是表示 128 位資料型別。double相比,decimal 型別具有更高的精度和更小的範圍,它適合於財務和貨幣計算。
decimal:
有效位:±1.0 × 10(-28次方) 到 ±7.9 × 10(28次方)
精度:28 到 29 位
double:
有效位:±5.0 × 10(-324次方) 到 ±1.7 × 10(308次方)
精度:15 到 16 位
3樓:匿名使用者
select convert(decimal(38, 2),vehicle_mode) from vehicles
上面正解
4樓:匿名使用者
select round(123456.456,2) from product ;/小數點右邊保留兩位小數然後四捨五入回
答select round(123456.456) from dual;//四捨五入
select trunk(12345.5525,2) from dual;直接擷取兩位不四捨五入
5樓:
select round(agreeprice,2) from product
6樓:匿名使用者
select convert(decimal(10, 2),欄位) from 表
mysql資料庫,結果保留4位小數,小數點後四位
7樓:匿名使用者
select title , round(click/charge,4)
from table
where date< '2007-7-7 00:00:00'
round()是四捨五入
8樓:
在欄位前面加 convert(decimal(12,4),click)
轉換成dectmal型別 第二個引數就是小數4位
+分吧!
如何讓float變數精確到小數點後兩位
9樓:育知同創教育
比如:long i = long.maxvalue - 12345678901234l;
float f = i;
double d = i;
console.writeline( "long i : ", i);
console.writeline( "float f = i: ", f);
console.writeline( "(double)f : ", (double)f);
console.writeline( "(long)f : ", (long)f);
console.writeline( "double d = i: ", d);
console.writeline( "(long)d : ", (long)d);
console.writeline( "d - f : ", d - f);
10樓:匿名使用者
float spd = 22.518744;
char buf[10];
sprintf(buf, "%.2f", spd);
sscanf(buf, "%f", &spd);
在mysql資料庫中如何讓某個欄位有重複的只取一條
保留相 同a值的最小id行 select from table a a where not exists select 1 from table a bwhere b.a a.a and b.id a.id select from table a where id in select min id ...
mysql如何去除兩個欄位資料相同的記錄
假設你的表名是mytable,可能含有相同資料的欄位是numa和numb,那麼刪除兩個欄位資料相內同的記錄方法容為 1.查詢具有相同資料的記錄 select from mytable where numa in select numb from mytable 2.進行刪除 delete mytab...
如何在mysql中group by week
首先上面的語句是列出 user name 和 age 是會報錯的。其次,想統計age 的資料,肯定是要以age 為分組的,我寫了一條語句不知道能不能滿足你的需求 select age from user group by age order by count age desc 然後你只取第一條資料就...