1. 問個sql語句,查詢到的數據,除以2,余數四捨五入,如何寫
假設你要更新的表為books,列為price,當前要更新的數據ID(標識列)為1
update
books
set
price=(select
round((select
price
from
books
where
id=1)/2,1))
where
id=1
下面來說明
1.
select
price
from
books
where
id=1
查出你要更新的初始價格是多少
2.
用select
round(數字,精度)來四捨五入
例如select
round(63.543,1)
結果為63.5
3.
將四捨五入的值更新到表中
update
books
set
price=(select
round((select
price
from
books
where
id=1)/2,1))
where
id=1
希望樓主能有用
2. sql四捨五入取整語句
使用ROUND(X) 進行操作:返回參數X的四捨五入的一個整數。比如說:
3. 問個SQL語句,查詢到的數據,除以2,余數四捨五入,如何寫
假設你要更新的表為books,列為price,當前要更新的數據ID(標識列)為1
update books set price=(select round((select price from books where id=1)/2,1)) where id=1
下面來說明
1.
select price from books where id=1
查出你要更新的初始價格是多少
2.
用select round(數字,精度)來四捨五入
例如select round(63.543,1)
結果為63.5
3.
將四捨五入的值更新到表中
update books set price=(select round((select price from books where id=1)/2,1)) where id=1
希望樓主能有用
4. sql怎樣四捨五入保留小數點後1位
select cast('8.5738' as numeric(10,1)),基本上數字只要是四捨五入都可以轉成numerice,後面2個參數,1代表數字長度,2代表小數點後的位數,你將你sql中的round去掉應該就行
5. sql 四捨五入問題
在這種情況下,您會得到82.3的結果:
DECLARE @DEC DECIMAL(12,1)
SELECT @DEC=ROUND(82.305,2)
SELECT @DEC
或在前台顯示過程中截斷了後面的位數
而下面的查詢結果,則是正確的(82.31):
SELECT ROUND(82.305,2)
或
DECLARE @DEC DECIMAL(12,2)
SELECT @DEC=ROUND(82.305,2)
SELECT @DEC
6. 關於sql四捨五入問題
select cast(100.581 as decimal(15,2)) --自動四捨五入
select cast(ceiling(100.581 * 100)/100 as decimal(15,2))
select cast(floor(100.581 * 10)/10 as decimal(15,1))
7. sql查詢語句查詢結果是數值小數點後自動四捨五入取小數點後4位,可以怎麼寫
select convert(decimal(18,4),dj) from table
8. sql 貨幣四捨五入
1> SELECT ROUND(1.56, 0), ROUND(1.56,1), ROUND(12.34, -2)
2> go
----- ----- ------
2.00 1.60 .00
(1 行受影響)
ROUND 函數可以處理 四捨五入
SQL Server 2005 可以用的, 2000沒環境測試。
9. SQL如何四捨五入
update item set sale_price = price 理解為賣價最終會等於進價了。
如果是要把賣價等於進價四捨五入,則
update item set sale_price = cast(round(price,1) as numeric(15,1))
如果不滿足您的需求,請繼續追問,在線解答。
10. sql語句怎麼寫「四捨五入後求和」的語句
select
cast('123.456'
as
decimal)
將會得到
123(小數點後面的將會被省略掉)。
如果希望得到小數點後面的兩位。
則需要把上面的改為
select
cast('123.456'
as
decimal(38,
2))
===>123.46
自動四捨五入了!