當前位置:編程學習大全網 - 腳本源碼 - 問個SQL語句,查詢到的數據,除以2,余數四舍五入,如何寫?

問個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

希望樓主能有用

  • 上一篇:小三懷孕生下來的後果 最慘淡的結果沒名沒分變成未婚媽媽
  • 下一篇:周幾的英文怎麽說
  • copyright 2024編程學習大全網