< ="Content-" content="text/; charset=utf-8">< name="ProgId" content="Word.">< name="Generator" content="Microsoft Word 12">< name="Originator" content="Microsoft Word 12">
<>
As per point 3 we are using a join. See the SQL statement below do you have any further ideas?
select election.election_ref,
election.election_id,
election.combined_1,
election.combined_2,
election.combined_3,
election_c1.main_election,
election_c1.election_ref e_ref_c1,
election_c2.election_ref e_ref_c2,
election_c3.election_ref e_ref_c3,
election.election_date,
election.mixed_title,
election.election_title,
election_level.elec_area_type,
election_station.station_letters,
electoral_area.area_code,
electoral_area.area_name,
electoral_area.ward_number,
elec_station_link.station_number,
elec_station_link.station_id,
elec_station_link.station_type,
ballot_requirements.ballot_box_no,
ballot_requirements.ballot_box_lett,
polling_reg.split,
polling_reg.polling_reg_id,
premises.premise_name,
premises.premise_add1,
premises.premise_add2,
electoral_area_c1.area_name a_name_c1,
electoral_area_c1.ward_number w_num_c1,
election_level_c1.elec_area_type ea_type_c1, electoral_area_c2.area_name
a_name_c2, electoral_area_c2.ward_number w_num_c2,
election_level_c2.elec_area_type
ea_type_c2, electoral_area_c3.area_name a_name_c3, electoral_area_c3.ward_number
w_num_c3, election_level_c3.elec_area_type
ea_type_c3, parameters.pd_name from er30 election left outer join er30
election_c1 on election_c1.election_id=election.combined_1
left outer join er30 election_c2 on election_c2.election_id=election.combined_2
left outer join er30 election_c3 on
election_c3.election_id=election.combined_3
left outer join er06 election_level on
election_level.elec_level_id=election.elec_level_id
left outer join er33 election_link on
election_link.election_id=election.election_id
left outer join er08 electoral_area on
electoral_area.area_id=election_link.elec_area_id
left outer join er107 elec_station_link on
(elec_station_link.election_id=election_link.election_id
and elec_station_link.elec_area_id=election_link.elec_area_id)
left outer join er108 ballot_requirements on
ballot_requirements.pollreg_stat_id=elec_station_link.pollreg_stat_id
left outer join er102 polling_reg on
polling_reg.polling_reg_id=elec_station_link.polling_reg_id
left outer join er105 election_station on
election_station.station_id=elec_station_link.station_id
left outer join er47 premises on
premises.premise_id=election_station.premise_id
left outer join er107 elec_station_link_c1 on
elec_station_link_c1.pollreg_stat_id=elec_station_link.combined_stn_1
left outer join er08 electoral_area_c1 on
electoral_area_c1.area_id=elec_station_link_c1.elec_area_id
left outer join er06 election_level_c1 on
electoral_area_c1.elec_level_id=election_level_c1.elec_level_id
left outer join er107 elec_station_link_c2 on
elec_station_link_c2.pollreg_stat_id=elec_station_link.combined_stn_2
left outer join er08 electoral_area_c2 on
electoral_area_c2.area_id=elec_station_link_c2.elec_area_id
left outer join er06 election_level_c2 on
electoral_area_c2.elec_level_id=election_level_c2.elec_level_id
left outer join er107 elec_station_link_c3 on
elec_station_link_c3.pollreg_stat_id=elec_station_link.combined_stn_3
left outer join er08 electoral_area_c3 on
electoral_area_c3.area_id=elec_station_link_c3.elec_area_id
left outer join er06 election_level_c3 on
electoral_area_c3.elec_level_id=election_level_c3.elec_level_id,
er55 parameters
where elec_station_link.station_type='PS'
and (elec_station_link.required='Y'
or elec_station_link_C1.required='Y'
or elec_station_link_C2.required='Y'
or elec_station_link_C3.required='Y')