
SQL Queries Quiz
Quiz
•
Computers
•
University
•
Practice Problem
•
Hard
Shubhi U
Used 3+ times
FREE Resource
Enhance your content in a minute
13 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider a table named 'students' with columns 'id', 'name', and 'age'. Write a query to retrieve all the students whose age is greater than 18.
SELECT * FROM students WHERE age < 18;
SELECT * FROM students WHERE age >= 18;
SELECT * FROM students WHERE age > 18;
SELECT * FROM students WHERE age = 18;
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given two tables 'orders' and 'customers' with a common column 'customer_id', write a query to retrieve all the orders along with the customer details (name, email) for each order.
SELECT orders.*, customers.name, customers.email FROM orders JOIN customers ON orders.customer_id = customers.customer_id
SELECT orders.*, customers.name, customers.email FROM orders LEFT JOIN customers ON orders.customer_id = customers.customer_id
SELECT orders.*, customers.name, customers.email FROM orders RIGHT JOIN customers ON orders.customer_id = customers.customer_id
SELECT * FROM orders, customers WHERE orders.customer_id = customers.customer_id
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider a table named 'employees' with columns 'id', 'name', 'department_id', and a table named 'departments' with columns 'id' and 'name'. Write a query to retrieve the names of all employees along with their corresponding department names.
SELECT employees.name, departments.name FROM employees LEFT JOIN departments ON employees.department_id = departments.id
SELECT employees.name, departments.name FROM employees JOIN departments ON employees.department_id = departments.id
SELECT employees.name, departments.name FROM employees WHERE employees.department_id = departments.id
SELECT employees.name, departments.name FROM employees INNER JOIN departments ON employees.department_id = departments.id WHERE employees.department_id IS NOT NULL
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given a table named 'products' with columns 'id', 'name', and 'price', write a query to retrieve the product with the highest price.
SELECT * FROM products WHERE price = (SELECT AVG(price) FROM products)
SELECT * FROM products WHERE price = (SELECT MIN(price) FROM products)
SELECT * FROM products WHERE price = (SELECT SUM(price) FROM products)
SELECT * FROM products WHERE price = (SELECT MAX(price) FROM products)
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider a table named 'students' with columns 'id', 'name', and 'age'. Write a query to retrieve the names of all students whose name starts with the letter 'A'.
SELECT name FROM students WHERE name LIKE '_A%'
SELECT name FROM students WHERE name LIKE 'A%'
SELECT name FROM students WHERE name LIKE 'A_'
SELECT name FROM students WHERE name LIKE '%A'
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given two tables 'orders' and 'customers' with a common column 'customer_id', write a query to retrieve the total number of orders for each customer.
SELECT customers.customer_id, COUNT(orders.order_id) AS total_orders FROM customers JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customers.customer_id
SELECT customers.customer_id, COUNT(orders.order_id) AS total_orders FROM customers RIGHT JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customers.customer_id
SELECT customers.customer_id, COUNT(orders.order_id) AS total_orders FROM customers LEFT JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customers.customer_id
SELECT customers.customer_id, COUNT(orders.order_id) AS total_orders FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customers.customer_id
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider a table named 'employees' with columns 'id', 'name', 'department_id', and a table named 'departments' with columns 'id' and 'name'. Write a query to retrieve the names of all departments along with the count of employees in each department.
SELECT departments.name, COUNT(*) FROM departments JOIN employees ON departments.id = employees.department_id GROUP BY departments.name
SELECT departments.name, COUNT(employees.id) FROM departments JOIN employees ON departments.id = employees.department_id
SELECT departments.name, COUNT(employees.id) FROM departments LEFT JOIN employees ON departments.id = employees.department_id GROUP BY departments.name
SELECT departments.name, COUNT(employees.id) FROM departments JOIN employees ON departments.id = employees.department_id GROUP BY departments.name
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
NLP_Unit 1_Quiz
Quiz
•
University
10 questions
RDBMS
Quiz
•
University
15 questions
DBMS LAB QUIZ
Quiz
•
University
15 questions
RLNVSP - Buổi 1 - Ôn tập
Quiz
•
University
16 questions
CIS 1103 Week 7_8 CLO 3 (Part 3)
Quiz
•
University
10 questions
Big Data Analytics
Quiz
•
University
10 questions
Metodologías Ágiles
Quiz
•
University
10 questions
Chapter 5 Test Management Part 1
Quiz
•
University
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
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
20 questions
Figurative Language Review
Quiz
•
6th Grade
