What potential issue should be considered when using correlated subqueries?
They require the use of the JOIN clause.
They cannot return more than one column.
They cannot be used with aggregate functions.
They can lead to performance issues if not used carefully.
What is the purpose of the COUNT() function in SQL?
COUNT()
Returns the number of rows in a table
Calculates the sum of values in a column
Finds the minimum value in a column
Returns the average value of a column
In which scenario would a subquery be a more suitable choice than a JOIN operation?
When you need to filter data based on a condition that involves a separate query.
When you need to sort data from multiple tables based on a common column.
When you need to update data in one table based on data from another table.
When you need to combine data from multiple tables based on a common column.
You are using a subquery to fetch a list of product IDs from an 'Orders' table. What is the main purpose of using the DISTINCT keyword within this subquery?
To limit the number of product IDs returned.
To filter product IDs based on a specific condition.
To retrieve only unique product IDs, eliminating duplicates.
To sort the product IDs in ascending order.
What is the primary clause used to retrieve data from a table in SQL?
FETCH
RETRIEVE
SELECT
GET
You want to find customers who have placed orders in the last month. You have two tables: 'Customers' and 'Orders'. Which subquery type would be most efficient to achieve this?
EXISTS Subquery
Any of the above would be equally efficient.
IN Subquery
Correlated Subquery
What is the result of SELECT NOW(); in SQL?
SELECT NOW();
Current date and time
An error message
Current date
Current time
What SQL clause is used to group rows with the same value in one or more columns into a summary row?
ORDER BY
WHERE
GROUP BY
How would you select the top 5 highest-scoring games from a table named 'games' with a column called 'score'?
SELECT * FROM games ORDER BY score DESC LIMIT 5;
SELECT * FROM games ORDER BY score ASC LIMIT 5;
SELECT * FROM games WHERE score LIMIT 5;
SELECT TOP 5 * FROM games ORDER BY score DESC;
Which comparison operator means 'not equal to' in SQL?
<>
!=
<
=