先說結論,正确的方法類似如下語句:
select vat from expenses where round(vat::numeric, 2) = 19.66;
而不能直接用相等:
select vat from expenses where vat = 19.66;
參考:
http://www.peterbe.com/plog/comparing-real-values
當你遇到諸如0.01的值時直接使用=則得不到你想要的結果。
先說結論,正确的方法類似如下語句:
select vat from expenses where round(vat::numeric, 2) = 19.66;
而不能直接用相等:
select vat from expenses where vat = 19.66;
參考:
http://www.peterbe.com/plog/comparing-real-values
當你遇到諸如0.01的值時直接使用=則得不到你想要的結果。