postgresql7.1 select survey_response__initial_response_id(:response_id) as initial_response_id from dual select count(*) from survey_responses where survey_id=:survey_id and survey_response__initial_user_id(response_id)=:user_id and initial_response_id is null