我无法将双精度值转化为金钱。
SELECT scrap_cost.year AS year
, scrap_cost.weekly AS week
, scrap_cost.scrap_cost::MONEY
, labor_cost.labor_cost::MONEY
FROM ...
返回
ERROR: cannot cast type double precision to money
LINE 4: ..., scrap_cost.scrap_cost::MONEY, labor_cost.labor_cost::money
^
********** Error **********
ERROR: cannot cast type double precision to money
SQL state: 42846
Character: 117
答案 0 :(得分:3)
我要解决的问题是将其作为numeric
第一个
SELECT
scrap_cost.year AS year
, scrap_cost.weekly AS week
, scrap_cost.scrap_cost::MONEY
, labor_cost.labor_cost::NUMERIC::MONEY
FROM ...
我在postgres documentation
中找到了解决方案