postgresql7.1 select s.name as name, question_id, question_text, presentation_type, sort_order, active_p, required_p, s.section_id as section_id, branch_p, q.pretty_id as question_pretty_id, s.pretty_id as section_pretty_id from survey_questions q right outer join survey_sections s on (q.section_id = s.section_id) where survey_id=:survey_id order by s.sort_key,s.section_id, sort_order