select Branch, CUST, sum(PAY_SALES) PAY_SALES,sum(RECEIVE_SALES) RECEIVE_SALES,
sum(REC_PAY_SALES) EARNINGS,sum(TKTSCNT) TKTSCNT from
(select
'HO' Branch,,
sum(ticket_net_payable*ticket_ex_rate)PAY_SALES, sum(ticket_net_receivable*ticket_ex_rate) RECEIVE_SALES,
sum(((ticket_net_receivable*ticket_ex_rate)-(ticket_net_payable*ticket_ex_rate))) REC_PAY_SALES,
count(ticket_number) TKTSCNT
from
ke014t3.ticket_view_t3
where
ticket_date between '01-JAN-2019' and '31-DEC-2019'
--and ticket_status='S'
group by 'HO', '2019' 
union all
select
'UN' Branch,'2019' YEAR,
sum(ticket_net_payable*ticket_ex_rate)PAY_SALES, sum(ticket_net_receivable*ticket_ex_rate) RECEIVE_SALES,
sum(((ticket_net_receivable*ticket_ex_rate)-(ticket_net_payable*ticket_ex_rate))) REC_PAY_SALES,
count(ticket_number) TKTSCNT
from
ke019t3.ticket_view_t3
where
ticket_date between '01-JAN-2019' and '31-DEC-2019'
--and ticket_status='S'
group by 'UN', '2019')
group by branch,year
order by RECEIVE_SALES desc

