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小數除以整數求余數
取余數應該是
select 10.5 % 3