select sd business_date decode th tran_type SALE ti qty RETURN -1 ti q

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
select
sd.business_date,
decode(th.tran_type,'SALE',ti.qty,'RETURN',-1*ti.qty,1) count_resa,
ti.qty, -- <= я добавил
ti.unit_retail*decode(th.tran_type,'SALE',1,'RETURN',-1,1) sum_resa
from rms.sa_store_day sd,
sa_tran_head th,
sa_tran_item ti
where th.STORE_DAY_SEQ_NO=SD.STORE_DAY_SEQ_NO
and ti.tran_seq_no=th.tran_seq_no
and ti.item='23456100005'
and th.status='P'
and ti.qty<>1
-- and th.tran_seq_no = 802091002