Imagem de fundo

Analise a definição das tabelas “candidato” e “pagamento”...

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);


Script 1


Considerando os registros existentes na tabela “candidato”, qual consulta SQL seria necessária executar no PostgreSQL, versão 9.2, para que se obtenha EXATAMENTE o mesmo resultado da figura 1?



nome

character varying (50)

tem_nome_social

boolean

1

ALESSANDRA BENERI

f

2

ANDRE CARDOSO

f

3

CARLOS FERNANDEZ

f

4

DANIEL OLIVEIRA

f

5

FERNANDO SIQUEIRA

f

6

JOANA GONZALES

t

7

PAULO SILVEIRA

t


Figura 1 - Resultado esperado.


A

select nome, nome_social::boolean as tem_nome_social from candidato order by 1


B

select nome, (nome_social is false) as tem_nome_social from candidato order by 1


C

select nome, (nome_social is true) as tem_nome_social from candidato order by 1


D

select nome, cast(nome_social as boolean) as tem_nome_social from candidato order by 1


E

select nome, (nome_social is not null) as tem_nome_social from candidato order by 1