SELECT min(R.member_id) minId,max(R.member_id) maxId from t_reply R INNER JOIN m_answer A ON R.enquete_id = A.enquete_id AND R.question_id = A.question_id AND A.DEL_FLG =0 INNER JOIN m_question Q ON R.enquete_id = A.enquete_id AND R.question_id = A.question_id AND R.answer_id = A.answer_id AND R.question_no = Q.question_no AND Q.DEL_FLG = 0 WHERE Q.enquete_id = /*enquete_id*/ AND R.enquete_id = /*enquete_id*/ and R.member_id is not null