I have two tables and I want to get the name
of the A
table depending on Num3
. For example, in the A
table, we have num2
and in the B
table there are values corresponding to Num1
.
What I want is that name
appear repeated the number of times corresponding to the maximum number of num3
related to num2
.
For example, num2 = 3
has num3
max 4
, that is, when it appears 4 times
Using these tables:
-- A (name,Num2, local)
insert into A values ('Favela',1,'WE');
insert into A values ('Lamosa',2,'NA');
insert into A values ('Luz',3,'S0');
-- B (Num1,name,Num2, Num3)
insert into B values (1,'Maria',1,1);
insert into B values (2,'Jorge',2,1);
insert into B values (3,'Teresa',2,1);
insert into B values (4,'Rui',3,1);
insert into B values (1,'Fran',3,3);
insert into B values (2,'Juliett',3,3);