I have two queries here :
Query 1:
SELECT allowdeductname_en, SUM(SFD_comp_value_tax@;emp_id) as
GGG
FROM TPYDPROCMTDD md
LEFT JOIN TPYDPROCMTDH mh on md.procmtdh_id = mh.procmtdh_id and
md.company_id = mh.company_id
WHERE md.allowdeducttype = 'A'
AND md.company_id = '13565'
AND mh.company_id = '13565'
AND year(mh.paydate) = 2017
AND month(mh.paydate) = 1
AND mh.costcenter_code = 99990001
group by allowdeductname_en
order by allowdeductname_en
Query 2:
SELECT distinct allowdeductname_en
FROM TPYDPROCMTDD md
LEFT JOIN TPYDPROCMTDH mh on md.procmtdh_id = mh.procmtdh_id and
md.company_id = mh.company_id
WHERE md.allowdeducttype = 'A'
AND md.company_id = '13565'
AND mh.company_id = '13565'
AND year(mh.paydate) = 2017
AND month(mh.paydate) = 1
order by allowdeductname_en
Result For Query 1 and Query 2:

Is there anyway that I can intersect, join or union both of these queries so that it will look something like this :
I have tried so many different ways of doing it but still couldn't get the results I want. Guys PLEASE help !

cast(null as int) as gggallowdeductname_enreside in? AndSUM(SFD_comp_value_tax@;emp_id)is probably a typo. Can you please correct it?