SELECT A.*
         , (SELECT sum(X.total_cnt) FROM RS_MST X WHERE X.gd_mst_seq = A.gd_mst_seq AND X.tour_day_st = A.tour_day_st AND X.rs_status_cd not in ('RSSTAA004','RSSTAA007','RSSTAA008') AND X.use_yn = 'Y') AS rs_cnt
FROM GD_MST_PAY A
WHERE A.gd_mst_seq = :gd_mst_seq
AND A.tour_day_st > :today
AND A.use_yn = 'Y'
ORDER BY A.tour_day_st ASC
LIMIT 1