다음과 같아 Query를 작성 했는데 하나로 표시 하고자 합니다
select  A. tick_kind, A. tick_id, A. com_id, A. comp_id, sum(A. ti_qty) as cqty, 0 as pqty
from tbl_ticksale A join tbl_tickbase B
                    on A. tick_kind = B. tick_kind
                    and A. tick_id = B. tick_id
                    and A. com_id = B. com_id
                   
where A. tick_kind = '01'
  and A. com_id ='H'
  and A. comp_id ='h01'
  and B. tick_id ='075010022537'
group by A. tick_kind, A. tick_id, A. com_id, A. comp_id


union

select  C. tick_kind, C. tick_id, C. com_id, C. comp_id, 0 as cqty, sum(C. ti_qty) as pqty
from tbl_tickre C join  tbl_tickbase D
                  on C. tick_kind = D. tick_kind
                  and C. tick_id = D. tick_id
                  and C. com_id = D. com_id

where C. tick_kind ='01'
  and C. com_id ='H'
  and C. comp_id = 'H01'
  and D. tick_id ='075010022537'
 
group by C. tick_kind, C. tick_id, C. com_id, C. comp_id


결과 값


 tick_kind          tick_id           com_id         comp_id       cqty       pqty

------------        -----------         ---------         -----------     -------     -------

   01             075010022537         H                  H01           0             1

   01             075010022537         H                  H01           1             0


원하는 값          


tick_kind          tick_id           com_id         comp_id       cqty       pqty

------------        -----------         ---------         -----------     -------     -------

   01             075010022537         H                  H01           1             1