0
I have the tables:
-- NORTE --
create table tb_indices_norte(
id_norte int not null auto_increment,
localidade varchar(30),
sem_epi int not null,
totOvos smallint,
num_pos smallint,
num_inst smallint,
ipo decimal(5,1),
ido decimal(5,1),
ano varchar(4),
primary key(id_norte)) default charset = utf8;
-- SUL --
create table tb_indices_sul(
id_sul int not null auto_increment,
localidade varchar(30),
sem_epi int not null,
totOvos smallint,
num_pos smallint,
num_inst smallint,
ipo decimal(5,1),
ido decimal(5,1),
ano varchar(4),
primary key(id_sul)) default charset = utf8;
-- LESTE --
create table tb_indices_leste(
id_leste int not null auto_increment,
localidade varchar(30),
sem_epi int not null,
totOvos smallint,
num_pos smallint,
num_inst smallint,
ipo decimal(5,1),
ido decimal(5,1),
ano varchar(4),
primary key(id_leste)) default charset = utf8;
-- OESTE--
create table tb_indices_oeste(
id_oeste int not null auto_increment,
localidade varchar(30),
sem_epi int not null,
totOvos smallint,
num_pos smallint,
num_inst smallint,
ipo decimal(5,1),
ido decimal(5,1),
ano varchar(4),
primary key(id_oeste)) default charset = utf8;
How should I proceed to make a SELECT that returns me to SUM(totOvos), SUM(num_pos), SUM(num_inst) among the 4 tables WHERE ano = 'X' AND sem_epi BETWEEN 'Y' AND 'Z' GROUP BY sem_epi
I am beginner in SQL, I know I must define the PRIMARY KEYS and FOREIGN KEY, my problem is just this, how to define in the tables and how to create this SELECT.
Could not be a table and a key indicating the cardinal point (n s l o) !? I did not understand the model, confess. Controls what ? Search by SELECT UNION can be an output
– Motta
Thanks for the tip. I will research further up the UNION.
– Amiraldo Rodrigues Filho