select count(*)
from survey_questions
where section_id = :section_id
update survey_sections set sort_key=sort_key-1 where
survey_id=:survey_id and
sort_key>(
select sort_key from survey_sections where section_id=:section_id)
select section_id as replacement_section from survey_sections
where survey_id=:survey_id and sort_key=1 and section_id!=:section_id
select condition from survey_branches where section_id=:section_id
delete from survey_conditions where condition_id=:condition_id
delete from survey_branches where section_id=:section_id
update survey_branches set after=:replacement_section where after=:section_id