

Seu próximo nível começa aqui
Seu desenvolvimento não pode ter limites. Garanta sua Assinatura Ilimitada e libere uma preparação completa com os melhores professores do Brasil.
Analise a definição das tabelas “candidato” e “pagamento”, bem como os registros que foram inseridos. Responda às questões 11, 12, 13 e 14, considerando o script 1.
create table candidato
(
inscricao integer,
nome character varying(50),
nome_social character varying(50),
primary key(inscricao)
);
insert into candidato
values
(1, 'PAULO SILVEIRA', 'CLAUDIA SILVEIRA'),
(2, 'ANDRE CARDOSO', NULL),
(3, 'JOANA GONZALES', 'MARCOS GONZALES'),
(4, 'ALESSANDRA BENERI', NULL),
(5, 'FERNANDO SIQUEIRA', NULL),
(6, 'CARLOS FERNANDEZ', NULL),
(7, 'DANIEL OLIVEIRA', NULL);
create table pagamento
(
id_arquivo integer,
nosso_numero character varying(17),
dt_liquidacao date,
vlr_recebido double precision,
primary key(id_arquivo, nosso_numero)
) ;
insert into pagamento
values
(1, '90293840000000001', '2018-02-11', 90),
(1, '90293849999999991', '2018-02-11', 90),
(1, '90293840000000002', '2018-02-11', 90),
(2, '90293840000000003', '2018-02-12', 90),
(2, '90293840000000004', '2018-02-12', 90),
(3, '90293849999999992', '2018-02-13', 90),
(3, '90293840000000005', '2018-02-13', 90);
O diretor responsável pela organização do Processo Seletivo do IFRS solicitou ao Departamento de Tecnologia da Informação (DTI) um relatório que tornasse possível identificar:
A condição lógica, que identifica que uma inscrição foi paga, é esta:
Diante do contexto apresentado, qual consulta SQL, ao ser executada no banco de dados PostgreSQL, versão 9.2, contempla EXATAMENTE o que foi solicitado na figura 2?
nosso_numero character varying(17) | dt_liquidacao date | vlr_recebido double precision | inscricao integer | nome character varying(50) | status text | |
1 | 90293840000000001 | 2018-02-11 | 90 | 1 | PAULO SILVEIRA | PAGO |
2 | 90293840000000002 | 2018-02-11 | 90 | 2 | ANDRE CARDOSO | PAGO |
3 | 90293840000000003 | 2018-02-12 | 90 | 3 | JOANA GONZALES | PAGO |
4 | 90293840000000004 | 2018-02-12 | 90 | 4 | ALESSANDRA BENERI | PAGO |
5 | 90293840000000005 | 2018-02-13 | 90 | 5 | FERNANDO SIQUEIRA | PAGO |
6 | 90293849999999991 | 2018-02-11 | 90 | DESCONHECIDO | ||
7 | 90293849999999992 | 2018-02-13 | 90 | DESCONHECIDO | ||
8 | 6 | CARLOS FERNANDEZ | PENDENTE | |||
9 | 7 | DANIEL OLIVEIRA | PENDENTE |
Figura 2 - Resultado esperado
select pag.nosso_numero, pag.dt_liquidacao, pag.vlr_recebido, ins.inscricao, ins.nome, case when (id_arquivo is not null and inscricao is not null) then 'PAGO' when (id_arquivo is not null) then 'DESCONHECIDO' when (inscricao is not null) then 'PENDENTE' end as status
from pagamento pag
full join candidato ins on ins.inscricao = right(pag.nosso_numero, 10)::bigint
order by nosso_numero
select pag.nosso_numero, pag.dt_liquidacao, pag.vlr_recebido, ins.inscricao, ins.nome, case when (id_arquivo is not null and inscricao is not null) then 'PAGO' when (id_arquivo is not null) then 'DESCONHECIDO' when (inscricao is not null) then 'PENDENTE' end as status
from pagamento pag
all join candidato ins on ins.inscricao = right(pag.nosso_numero, 10)::bigint
order by nosso_numero
select pag.nosso_numero, pag.dt_liquidacao, pag.vlr_recebido, ins.inscricao, ins.nome, case when (id_arquivo is not null and inscricao is not null) then 'PAGO' when (id_arquivo is not null) then 'DESCONHECIDO' when (inscricao is not null) then 'PENDENTE' end as status
from pagamento pag
full join candidato ins on ins.inscricao = left(pag.nosso_numero, 10)::bigint
order by nosso_numero
select pag.nosso_numero, pag.dt_liquidacao, pag.vlr_recebido, ins.inscricao, ins.nome, case when (id_arquivo is not null and inscricao is not null) then 'PAGO' when (id_arquivo is not null) then 'DESCONHECIDO' when (inscricao is not null) then 'PENDENTE' end as status
from pagamento pag
right join candidato ins on ins.inscricao = left(pag.nosso_numero, 10)::bigint
order by nosso_numero
select pag.nosso_numero, pag.dt_liquidacao, pag.vlr_recebido, ins.inscricao, ins.nome, case when (id_arquivo is not null and inscricao is not null) then 'PAGO' when (id_arquivo is not null) then 'DESCONHECIDO' when (inscricao is not null) then 'PENDENTE' end as status
from pagamento pag
left join candidato ins on ins.inscricao = right(pag.nosso_numero, 10)::bigint
order by nosso_numero