LoginSignup
0

More than 5 years have passed since last update.

SQLクエリでsatoshiで記録されているものをbtc表記にするメモ

Last updated at Posted at 2016-11-21

単純に1e-8するだけだと浮動小数点の誤差がでるので桁を指定してroundで四捨五入する

select round(satoshi * 1e-8, 8) as btc from user_balances;

集計する場合は先にsumしてから四捨五入する

select round(sum(satoshi) * 1e-8, 8) as btc from user_balances;

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0