postgresql7.1 select sq.response_id, sq.question_id, sq.email, sq.first_names, sq.last_name, sq.user_id, to_char(sq.creation_date,'YYYY-MM-DD HH24:MI:SS') as creation_date, resp.boolean_answer, resp.number_answer, resp.date_answer, resp.varchar_answer, resp.clob_answer, resp.attachment_answer, resp.label from (select sqr.response_id, sqr.question_id, sqr.boolean_answer, sqr.number_answer, sqr.date_answer, sqr.varchar_answer, sqr.clob_answer, sqr.attachment_answer, sqc.label, sqc.sort_order from survey_responses sr, survey_question_responses sqr left join survey_question_choices sqc using(question_id,choice_id) where sr.survey_id=:survey_id and sr.response_id=sqr.response_id) resp, (select r.response_id, q.question_id, u.email, u.first_names, u.last_name, r.user_id, r.creation_date, q.abstract_data_type, q.sort_order from survey_questions q, (select initial_user_id as user_id, creation_date, response_id from survey_responses_latest where survey_id=:survey_id) r, (select p.email, u.first_names, u.last_name, u.person_id as user_id from parties p, persons u where p.party_id=u.person_id) u, survey_sections ss where ss.survey_id=:survey_id and q.section_id=ss.section_id and r.user_id=u.user_id) sq where sq.response_id = resp.response_id and sq.question_id = resp.question_id order by sq.response_id, sq.sort_order, sq.question_id, resp.sort_order