sql做查詢的時候,怎麼把decimal型別的資料保留兩位小數

2021-04-18 09:25:51 字數 860 閱讀 6872

1樓:素顏以對

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 位

2樓:匿名使用者

select convert(decimal(38, 2),vehicle_mode) from vehicles

上面正解

3樓:匿名使用者

select round(123456.456,2) from product ;/小數點右邊保留兩位小數然後四捨五入回

答select round(123456.456) from dual;//四捨五入

select trunk(12345.5525,2) from dual;直接擷取兩位不四捨五入

4樓:

select round(agreeprice,2) from product

5樓:匿名使用者

select convert(decimal(10, 2),字段) from 表

怎麼合併兩個sql語句的查詢結果

select id 1,name 李某某 union all select 2,王某某union all select 2,王某某這樣合併不會去重 不要all 內部會有個去重操作 但是有all時後效率比沒all 高 select id,name from table1union select id,...

SQL指定查詢N行到N行的語句怎麼寫

select from test where rownum 10 and rownum 30 機子上沒裝oracle啊,不過好像記得這樣是可以的,你試試還有啊,你想選什麼樣的,最好加上order by 用分頁的方法 這是我分頁的儲存過程 if exists select from sysobject...

怎麼用sql查詢班級前十名成績的同學的姓名和分數(成績相同的學生算同名次)

select name,score from select name,score,dense rank over order by score row from t where row 10 取到排名的前十位 with rk as select stu score,stu name,dense ra...