
Consultas SQL
Authored by Cácio Silva
Computers
1st Grade
Used 10+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
Sabendo que a tabela EMPRESTIMO (id, cpf, valor, data) possui relacionamento com CLIENTE (cpf, nome). Que EMPRESTIMO possui uma chave artificial gerenciada pelo MySQL. E que todos os campos de EMPRESTIMO são obrigatórios.
Qual comando cria corretamente a tabela EMPRESTIMO?
CREATE TABLE emprestimo (
id bigint not null auto_increment,
cpf varchar(14) not null,
valor float not null,
data date not null,
primary key (id),
foreign key cliente_fk (cpf) references cliente (cpf)
);
CREATE TABLE emprestimo (
id bigint not null,
cpf varchar(14) not null,
valor decimal(10,2) not null,
data date not null,
primary key (id),
foreign key cliente_fk (cpf) references cliente (cpf)
);
INSERT TABLE emprestimo (
id bigint not null auto_increment,
cpf varchar(14) not null,
valor decimal(10,2) not null,
data date not null,
primary key (id),
foreign key cliente_fk (cpf) references cliente (cpf)
);
CREATE TABLE emprestimo (
id bigint not null auto_increment,
cpf varchar(14) not null,
valor decimal(10,2) not null,
data date not null,
primary key (id),
foreign key cliente_fk (cpf) references cliente (cpf)
);
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Dada as tabelas CLIENTE (cpf, nome) e EMPRESTIMO (id, cpf, valor, data), qual a consulta pesquisa todos os clientes que FIZERAM empréstimos?
SELECT * FROM cliente
FULL JOIN emprestimo;
SELECT * FROM cliente
INNER JOIN emprestimo ON cpf = cpf;
SELECT * FROM cliente c
INNER JOIN emprestimo e ON c.cpf = e.cpf;
SELECT * FROM cliente c
RIGHT JOIN emprestimo e ON c.cpf = e.cpf;
3.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Dada as tabelas CLIENTE (cpf, nome) e EMPRESTIMO (id, cpf, valor, data), qual a consulta pesquisa o nome e o valor de todos os clientes que NÃO fizeram empréstimos?
SELECT * FROM clientes c
LEFT JOIN emprestimo e ON c.cpf = e.cpf;
SELECT nome, valor FROM clientes c
LEFT JOIN emprestimo e ON c.cpf = e.cpf
WHERE c.cpf = NULL;
SELECT nome, valor FROM clientes c
LEFT JOIN emprestimo e ON c.cpf = e.cpf
WHERE c.cpf IS NULL;
SELECT nome, valor FROM clientes c
LEFT JOIN emprestimo e ON c.cpf = e.cpf
WHERE e.cpf IS NULL;
4.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Data as seguintes tabelas, qual consulta que exibe o nome, o valor e o status das parcelas.
5.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
O cliente quer saber quais clientes estão inadimplentes.
Que consulta cria um relatório com o NOME DO CLIENTE e o VALOR TOTAL devido por ele?
Melhore a exibição mostrando primeiro as maiores parcelas.
SELECT c.nome, sum(p.valor)
FROM cliente c
INNER JOIN emprestimo e ON c.cpf = e.cpf
INNER JOIN parcela p ON e.id = p.emprestimo
GROUP BY c.nome
HAVING p.status = 'ATRASADA'
ORDER BY sum(valor) DESC;
SELECT c.nome, sum(p.valor)
FROM cliente c
INNER JOIN emprestimo e ON c.cpf = e.cpf
INNER JOIN parcela p ON e.id = p.emprestimo
WHERE p.status = 'ATRASADA'
GROUP BY c.nome
ORDER BY sum(valor) DESC;
SELECT c.nome, sum(p.valor)
FROM cliente c
INNER JOIN emprestimo e ON c.cpf = e.cpf
INNER JOIN parcela p ON e.id = p.emprestimo
WHERE p.status = 'ATRASADA'
GROUP BY c.nome
ORDER BY sum(valor);
6.
FILL IN THE BLANK QUESTION
3 mins • 1 pt
Sabendo que a chave primária da tabela PARCELA é o campo id, as interrogações para completar o relatório que exiba o relatório ao lado.
SELECT ??????
FROM cliente c
INNER JOIN emprestimo e ON c.cpf = e.cpf
INNER JOIN parcela p ON e.id = p.emprestimo
GROUP BY c.nome, e.valor, p.valor;
OBS.: não use nem espaços após vírgulas no campos!
7.
OPEN ENDED QUESTION
5 mins • Ungraded
Dada as tabelas CLIENTE (cpf, nome) e EMPRESTIMO (id, cpf, valor, data), o cliente quer saber o nome dos clientes e a quantidade de empréstimos feitos por eles. Digite a consulta que atenda ao requisito solicitado pelo cliente.
Evaluate responses using AI:
OFF
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Conosci Eoc-Desk?
Quiz
•
1st - 12th Grade
10 questions
Diplo Variables
Quiz
•
1st - 10th Grade
13 questions
Social Media - Sicherer Umgang mit sozialen Medien
Quiz
•
1st - 5th Grade
10 questions
Segurança na Internet
Quiz
•
1st - 4th Grade
12 questions
Typing
Quiz
•
KG - University
12 questions
Käitumine internetis
Quiz
•
1st - 12th Grade
13 questions
Principles of Programming
Quiz
•
KG - University
10 questions
EXCEL BÁSICO 3
Quiz
•
1st - 3rd Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
Discover more resources for Computers
20 questions
Telling Time to the Hour and Half hour
Quiz
•
1st Grade
10 questions
Life Cycle of a Frog
Quiz
•
1st - 2nd Grade
10 questions
Exploring Rosa Parks and Black History Month
Interactive video
•
1st - 5th Grade
20 questions
Place Value
Quiz
•
KG - 3rd Grade
10 questions
100th Day of School 1st/2nd
Quiz
•
1st - 2nd Grade
15 questions
Reading Comprehension
Quiz
•
1st - 5th Grade
10 questions
Identifying Physical and Chemical Changes
Interactive video
•
1st - 5th Grade
10 questions
Exploring the American Revolution
Interactive video
•
1st - 5th Grade