select term,dseq,sum((RQTY * price /100 ) * case CDI when 'I' then 1 when 'D' then -1 when 'C' then -1 else 1 end ) from iack where bhno='5183' and term+dseq in (select term+dseq from iack where bhno='5183' and CDI='C' ) group by term,dseq
select term,sum((RQTY * price /100 ) * case CDI when 'I' then 1 when 'D' then -1 when 'C' then -1 else 1 end ) from iack where bhno='5181' group by term
select * from iack where bhno='5181' and term+dseq in (select term+dseq from iack where bhno='5181' and tqty <> bfqty and tqty <>AFQTY and BFQTY <> AFQTY ) order by term,dseq,mgtime
select * from iack where bhno='5183' and term+dseq in (select term+dseq from iack where bhno='5183' and CDI='C' ) order by term,dseq,mgtime
select * from imat where bhno='5181' and term + dseq in (select term+dseq from iack where bhno='5181' and tqty <> bfqty and tqty <>AFQTY and BFQTY <> AFQTY )
select term,dseq,sum((RQTY * price /100 ) * case CDI when 'I' then 1