合并2个查询时出现“将数据类型varchar转换为数值错误”错误

时间:2019-12-16 17:16:00

标签: mysql union

我正在尝试使用UNION函数连接2个不同的查询,并且不断获取

  

将数据类型varchar转换为数字时出错

消息。可以帮我解决这个问题吗?

select 
I.item_id, 
P.from_location_id,
MAX(P.transfer_date) as transfer_date,
I.last_maintained_by,
I.created_by,
I.qty_received,
I.order_type,
p.approved
from p21_view_transfer_line as I
inner join p21_view_transfer_hdr as P on P.transfer_no = I.transfer_no
WHERE P.from_location_id = '150' 
GROUP BY
I.item_id,
P.from_location_id,
I.last_maintained_by,
I.created_by,
I.qty_received,
I.order_type,
p.approved

UNION 
(select 
    B.item_id,
    A.location_id,
    B.item_desc,
    A.primary_bin, 
    A.qty_on_hand, 
    A.moving_average_cost,  
    (A.qty_on_hand * A.moving_average_cost) as 'Inventory Value',
    C.class_description
from p21_view_inv_loc as A
Right Join inv_mast as B on A.inv_mast_uid = B.inv_mast_uid
Left Join class as C on B.class_id3 = C.class_id
where 
    A.qty_on_hand > 0 and
    A.location_id = '150')

0 个答案:

没有答案