0
votes

ORA-01790: expression must have same datatype as corresponding expression error message. Below is the sql I'm using. I cant really find whats causing the error please help.

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','')
);
1
Have you googled for ORA-01790? - giorgiga

1 Answers

1
votes

One of your columns had a different data type between your UNION queries. If I had to guess, I imagine the '' transaction_number is causing the issue, because the name implies it's a number, but you've made it text.