SQL Queries Quiz

SQL Queries Quiz

University

13 Qs

quiz-placeholder

Similar activities

Enterprise Applications

Enterprise Applications

University

15 Qs

IT Service Delivery Data Dissemination

IT Service Delivery Data Dissemination

University

12 Qs

Oracle SQL Basico

Oracle SQL Basico

University

10 Qs

ITPC 116 Section 6

ITPC 116 Section 6

University

10 Qs

SYS 1591

SYS 1591

University

10 Qs

Post Test Modul 5

Post Test Modul 5

University

11 Qs

Midterm Exam IM2B

Midterm Exam IM2B

University

9 Qs

Cuestionario de SQL

Cuestionario de SQL

12th Grade - University

17 Qs

SQL Queries Quiz

SQL Queries Quiz

Assessment

Quiz

Computers

University

Hard

Created by

Shubhi U

Used 3+ times

FREE Resource

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

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?