Olá pessoal Estou tentando criar uma consulta aqui, depois de diversas tentativas infrutíferas vim pedir ajuda à vocês Tenho basicamente a seguinte estrutura: create table Hospitais(
Código integer unique auto_increment not null,
Nome char(50) not null,
primary key (Código));
create table Enfermarias(
Código integer unique auto_increment not null,
Nome char(50) not null,
Hospital integer not null,
primary key (Código),
foreign key (Hospital) references Hospitais (Código));
create table Internação(
Código integer not null unique auto_increment,
Paciente integer not null,
Enfermaria integer not null,
primary key (Código, Paciente, Enfermaria),
foreign key (Paciente) references Pacientes (Num_Reg),
foreign key (Enfermaria) references Enfermarias (Código));
create table Consultas (
Código integer not null auto_increment,
Médico char(15) not null,
Paciente integer not null,
Hospital integer not null,
primary key (Código),
foreign key (Médico) references Médicos (CPF),
foreign key (Paciente) references Pacientes (Num_Reg),
foreign key (Hospital) references Hospitais (Código)); Preciso criar uma consulta que retorne os hospitais mais frequentados e a enfermaria mais movimentada de cada hospital. Estou tentando faz um tempão criar isso, mas não estou conseguindo, alguém tem uma luz?