SQL ORA-01790 表达式的数据类型必须与对应的表达式相同



ORA-01790:表达式必须与相应的表达式错误消息具有相同的数据类型。下面是我正在使用的sql。我真的找不到导致错误的原因,请帮助。

select distinct *
from
( select 
  h.billingaddress, 
  h.sold_to,
  '' as trx_number,
  '' as bs_number,
  apd.transaction_number
--      apd.transaction_number
from 
  amti_so_headers2 h
inner join
  amti_print_document apd
on 
  h.header_id = apd.header_id
where
  apd.transaction_number in ('9535','')
and
  (
    report_type = 'Billing Statement'
    or
    report_type = 'Sales Invoice'
  )
  UNION
select
  billingaddress,
  bill_to sold_to,
  amti_trx_header.trx_number,
  amti_trx_header.bs_number,
  '' transaction_number
from 
  amti_trx_header
where
  trx_number in ('','')
  or
  bs_number in ('9535','')
);

其中一个列在 UNION 查询之间具有不同的数据类型。 如果我不得不猜测,我想'' transaction_number导致了这个问题,因为名称暗示它是一个数字,但你已经把它变成了文本。

最新更新