运行查询时,我遇到了精确度错误。它来自** p之后的函数
我尝试将column数据类型更改为整数和to_number。这是一个varchar。
SELECT * , (tableb.difference - tablea.order_bloomnet_msg_price) As Answer
From
(Select order_bloomnet_msg_type, order_bloomnet_msg_text, order_bloomnet_num,order_bloomnet_msg_price, order_bloomnet_id
FROM pos.order_bloomnet_msg
Where order_bloomnet_msg_type = 'ORDR'
Order By order_bloomnet_num) as TableA
Inner Join
(Select Trunc(order_bloomnet_msg_sent) as Date,order_bloomnet_msg_username, order_bloomnet_msg_price as difference, order_bloomnet_num, order_bloomnet_id
FROM pos.order_bloomnet_msg
Where order_bloomnet_msg_type = 'PCHG'
Order By order_bloomnet_num) as TableB ON
(TableA.order_bloomnet_num = TableB.order_bloomnet_num and
TableA.order_bloomnet_id = TableB.order_bloomnet_ID )
Where order_bloomnet_msg_price is not Null and TableB.Date = '2019/01/03'
我希望最后一列具有TableB.difference和order_bloomnet_msg_price的结果
答案 0 :(得分:1)
您应该转换您的值以避免错误
赞
SELECT * , (tableb.difference::float - tablea.order_bloomnet_msg_price::float) As Answer
From
(Select order_bloomnet_msg_type, order_bloomnet_msg_text, order_bloomnet_num,order_bloomnet_msg_price, order_bloomnet_id
FROM pos.order_bloomnet_msg
Where order_bloomnet_msg_type = 'ORDR'
Order By order_bloomnet_num) as TableA
Inner Join
(Select Trunc(order_bloomnet_msg_sent) as Date,order_bloomnet_msg_username, order_bloomnet_msg_price as difference, order_bloomnet_num, order_bloomnet_id
FROM pos.order_bloomnet_msg
Where order_bloomnet_msg_type = 'PCHG'
Order By order_bloomnet_num) as TableB ON
(TableA.order_bloomnet_num = TableB.order_bloomnet_num and
TableA.order_bloomnet_id = TableB.order_bloomnet_ID )
Where order_bloomnet_msg_price is not Null and TableB.Date = '2019/01/03'