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.

SQL Queries Quiz

Quiz
•
Computers
•
University
•
Hard
Shubhi U
Used 3+ times
FREE Resource
13 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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
Create a free account and access millions of resources
Similar Resources on Quizizz
10 questions
KUIS DAY 3 STACK

Quiz
•
University
18 questions
Normalization of Data Quiz

Quiz
•
12th Grade - University
17 questions
Cuestionario de SQL

Quiz
•
12th Grade - University
10 questions
Oracle SQL Basico

Quiz
•
University
10 questions
ITPC 116 Section 6

Quiz
•
University
15 questions
ERP 1

Quiz
•
University - Professi...
12 questions
Database Design & Development SQL 2

Quiz
•
University
11 questions
Post Test Modul 5

Quiz
•
University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade