SELECT A.*
          , C.gd_nm
          , (SELECT SUM(X.pay_amt) FROM RS_PAY X WHERE X.rs_mst_seq = A.rs_mst_seq) AS pay_amt
          , FN_SY_CLASS_R01(A.rs_status_cd,'CLASS_NM') AS rs_status_nm
          , FN_SY_CLASS_R01(A.payment_sta_cd,'CLASS_NM') AS pay_status_nm
FROM RS_MST A
INNER JOIN GD_MST C ON A.gd_mst_seq = C.gd_mst_seq
WHERE A.rs_nm = :rs_nm AND replace(A.rs_hp,'-','') = :rs_hp
AND A.rs_mst_code = :rs_mst_code