Q1
True / FalseThe NOT IN operator is used to exclude rows that match the values in a specified list.
The NOT IN operator checks if a value is not within a list of values and excludes those rows from the result set.
Q2
True / FalseThe NOT IN operator can be used with subqueries.
The NOT IN operator can indeed be used with subqueries to exclude rows based on the result of another query.
Q3
True / FalseUsing NOT IN with a NULL value in the list will return no rows.
If the list contains a NULL value, the NOT IN operator will not exclude any rows because the comparison with NULL always returns UNKNOWN.
Q4
True / FalseThe NOT IN operator can be used to filter out rows where a column value is within a range of values.
The NOT IN operator is used to filter out rows based on a list of discrete values, not a range. For ranges, BETWEEN is more appropriate.
Q5
True / FalseThe NOT IN operator performs faster than the NOT EXISTS operator in all cases.
The performance of NOT IN versus NOT EXISTS depends on the specific scenario and data. There is no general rule that one is always faster than the other.
Q6
True / FalseThe NOT IN operator can be used with string values.
The NOT IN operator can be used with string values to exclude rows that match any value in a specified list of strings.
Q7
True / FalseThe NOT IN operator can be used to filter out rows with date values.
The NOT IN operator can be used with date values to exclude rows matching any date in a specified list.
Q8
True / FalseThe NOT IN operator is case-sensitive by default in SQL Server.
The case sensitivity of the NOT IN operator depends on the collation settings of the database. By default, SQL Server collation is case-insensitive.
Q9
True / FalseThe NOT IN operator can be combined with other logical operators such as AND and OR.
The NOT IN operator can be used in conjunction with other logical operators to create more complex filtering conditions.
Q10
True / FalseThe NOT IN operator can only be used with numeric values.
The NOT IN operator can be used with various data types, including numeric, string, and date values.
Q11
True / FalseWhen using the NOT IN operator, it is important to ensure that the subquery does not return any NULL values.
If the subquery used with NOT IN returns NULL values, the NOT IN condition will not exclude any rows because comparisons with NULL always yield UNKNOWN.
Q12
True / FalseThe NOT IN operator cannot be used with subqueries that return multiple columns.
The NOT IN operator requires the subquery to return a single column of values for comparison.
Q13
True / FalseThe NOT IN operator can be used in an UPDATE statement to filter rows to be updated.
The NOT IN operator can be used in the WHERE clause of an UPDATE statement to exclude rows that match the values in the specified list.
Q14
True / FalseThe NOT IN operator cannot be used with JOIN conditions.
The NOT IN operator is typically used in the WHERE clause, but it can be part of a condition in a join if necessary.
Q15
True / FalseThe NOT IN operator can be used in a DELETE statement to exclude rows that match certain values.
The NOT IN operator can be used in the WHERE clause of a DELETE statement to exclude rows from deletion based on the specified list of values.
Q16
Single ChoiceWhich of the following queries correctly uses the NOT IN operator to exclude rows with specific IDs?
SQL Code
SELECT *
FROM Employees
WHERE EmployeeID NOT IN (1, 2, 3);
This query correctly uses the NOT IN operator to exclude rows where EmployeeID is 1, 2, or 3.
Q20
Single ChoiceWhich query uses the NOT IN operator to exclude products from certain categories?
SQL Code
SELECT ProductName
FROM Products
WHERE CategoryID NOT IN (1, 2, 3);
This query excludes products from categories with IDs 1, 2, and 3 using the NOT IN operator.
Q24
Single ChoiceWhich query demonstrates a correct use of NOT IN to filter out specific order statuses?
SQL Code
SELECT OrderID, OrderDate
FROM Orders
WHERE OrderStatus NOT IN ('Cancelled', 'Returned');
This query uses the NOT IN operator to exclude orders with statuses 'Cancelled' and 'Returned'.
Q29
Single ChoiceWhich query uses NOT IN to exclude sales from specific regions?
SQL Code
SELECT SaleID, SaleAmount
FROM Sales
WHERE RegionID NOT IN (1, 2, 3);
The query uses the NOT IN operator to exclude sales from regions with IDs 1, 2, and 3.
Q33
Multiple ChoiceWhich query uses the NOT IN operator to filter out customers from specific countries?
SQL Code
SELECT CustomerName
FROM Customers
WHERE Country NOT IN ('Germany', 'France', 'Japan');
The query uses the NOT IN operator to exclude customers from Germany, France, and Japan.