SELECT A.ht_mst_seq
           ,A.ht_room_info_seq
           ,A.room_type
           ,FN_BA_CLASS_INFO_R01(A.room_type,'CLASS_NM') AS room_type_nm
           ,B.room_name
FROM HT_ROOM A
INNER JOIN HT_ROOM_INFO B ON A.ht_room_info_seq = B.ht_room_info_seq
WHERE day > :to_day
AND A.ba_comp_seq = :channel_comp_seq
 AND A.room_cnt - (SELECT COUNT(H.rs_hroom_seq) 
             FROM RS_HMST R
           INNER JOIN RS_HROOM H ON R.rs_hmst_seq = H.rs_hmst_seq
           WHERE R.ht_mst_seq = A.ht_mst_seq
           AND H.ht_room_seq = A.ht_room_seq
           ) > 0
GROUP BY A.ht_mst_seq,A.room_type,B.ht_room_info_seq