Вы можете использовать Union All, а затем рассчитать сумму:
select sum( as total_tax_charged)
from(
select sum(aila.total_rec_tax_amount) as total_tax_charged
from ap_invoice_lines_all aila
where aila.invoice_id = aia.invoice_id
and aila.line_type_lookup_code = 'ITEM'
and aila.tax_classification_code = 'VAT12 SERVICES'
group by aila.invoice_id
Union all
select sum(aila.total_rec_tax_amount)
from ap_invoice_lines_all aila
where aila.invoice_id = aia.invoice_id
and aila.line_type_lookup_code = 'ITEM'
and aila.tax_classification_code = 'VAT12 GOODS'
group by aila.invoice_id
)
Вы также можете сделать это с одним оператором выбора
select sum(aila.total_rec_tax_amount)
from ap_invoice_lines_all aila
where aila.invoice_id = aia.invoice_id
and aila.line_type_lookup_code = 'ITEM'
and aila.tax_classification_code in( 'VAT12 SERVICES', 'VAT12 GOODS')
group by aila.invoice_id