select 
  a.cucd, a.cuscd, a.cunm, a.spnm,
  a.vseq, a.gdflgnm, to_char(a.jdat,'yyyy/mm/dd') jdat,
  to_char(a.climit,'yyyy/mm/dd') climit, a.amt, a.amt2,
  a.chgnm, a.upchgnm, a.spktcd,
  a.cuiseq,
  count(*)  over ( partition by ktktcd ) as cnt,
  sum(amt)  over ( partition by ktktcd ) as tamt,
  sum(amt2) over ( partition by ktktcd ) as tamt2
from af203v02 a
where (:cucd is null or a.cucd=:cucd)
  and (:cuscd is null or a.cuscd=:cuscd)
  and (:vseq is null or a.vseq=:vseq)
  and (:jdats is null or a.jdat>=to_date(:jdats,'yyyy/mm/dd'))
  and (:jdate is null or a.jdat<=to_date(:jdate,'yyyy/mm/dd'))
  and (:chgcd is null or a.chgcd=:chgcd)
  and (:ktktcd is null or a.ktktcd=:ktktcd)
  and (:spktcd is null or a.spktcd=:spktcd)
order by a.cucd,a.cuscd, a.vseq, a.spktcd