select count(*) wcnt from (
    select cuiseq
        from afr3123
        where cls='23' and cls1='0' and sts='1'
            and ktktcd=:ktktcd and cucd=:cucd and cuscd=:cuscd
            and vseq=:vseq
    union all
    select a.cuiseq
        from axm99 b,afr3123 a
        where a.cls='23' and a.cls1='0' and a.sts='3'
            and a.ktktcd=:ktktcd and a.cucd=:cucd and a.cuscd=:cuscd
            and a.vseq=:vseq
            and a.ktktcd=b.ktktcd and a.sdat=b.sdday
)
