By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table funcionario (
id number(10) not null,
nome varchar(100) not null,
empresa varchar(100) not null,
primary key (id)
);
insert into funcionario (id, nome, empresa)
values (1, 'Mario da Silva Sauro', 'Toaldo Tulio Ltda.');
1 rows affected
insert into funcionario (id, nome, empresa)
values (2, 'Mario da Silva Sauro', 'Joao Falarz Ltda.');
1 rows affected
insert into funcionario (id, nome, empresa)
values (3, 'Homer Simpson', 'Usina Nuclear Mr. Burns');
1 rows affected
insert into funcionario (id, nome, empresa)
values (4, 'Robocop', 'OCP Enterprise');
1 rows affected
SELECT f1.nome, f3.empresa
FROM (SELECT nome
FROM funcionario
GROUP BY nome) f1
CROSS APPLY (SELECT f2.empresa
FROM funcionario f2
WHERE f1.nome = f2.nome
ORDER BY f2.empresa
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY) f3;
NOME | EMPRESA |
---|---|
Homer Simpson | Usina Nuclear Mr. Burns |
Mario da Silva Sauro | Joao Falarz Ltda. |
Robocop | OCP Enterprise |
select * from V$VERSION;
BANNER | BANNER_FULL | BANNER_LEGACY | CON_ID |
---|---|---|---|
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production | Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production Version 18.4.0.0.0 |
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production | 0 |