我是PG新手,想知道是否需要額外做任何事情來正確處理浮點數學。Postgres浮點數學 - 我需要做什麼特別的嗎?
例如,在紅寶石中使用BigDecimal
,在Elixir中使用Decimal
。
我在PG的最佳解決方案下面有什麼?
SELECT
COALESCE(SUM(active_service_fees.service_fee * (1::decimal - active_service_fees.withdraw_percentage_discount)), 0)
FROM active_service_fees
數據類型:
service_fee integer NOT NULL
withdraw_percentage_discount numeric(3,2) DEFAULT 0.0 NOT NULL
您不需要轉換爲小數。 –
你的數學沒有浮點數。 –
'withdraw_percentage_discount'是一個像'0.10'這樣的浮點數。這沒有資格嗎? – Tallboy