Q1
True / FalseThe AND operator returns true if both conditions are true.
The AND operator requires both conditions to be true to return true.
Q2
True / FalseThe OR operator returns true if at least one condition is true.
The OR operator requires at least one of the conditions to be true to return true.
Q3
True / FalseThe AND operator can be used to combine more than two conditions.
The AND operator can be used to combine multiple conditions.
Q4
True / FalseThe OR operator can only combine two conditions at a time.
The OR operator can combine multiple conditions, not just two.
Q5
True / FalseCombining conditions with AND always returns fewer rows than using OR.
Combining conditions with AND is more restrictive, generally returning fewer rows than OR.
Q6
True / FalseThe AND operator can be used to filter rows based on multiple columns.
The AND operator can be used to apply conditions on multiple columns in a query.
Q7
True / FalseThe OR operator can be used to check multiple columns for NULL values.
The OR operator can be used to check if any of the specified columns contain NULL values.
Q8
True / FalseThe AND operator has higher precedence than the OR operator in SQL Server.
In SQL Server, the AND operator has higher precedence than the OR operator.
Q9
True / FalseUsing parentheses can change the order of evaluation for AND and OR operators.
Parentheses can be used to explicitly define the order of evaluation for logical operators.
Q10
True / FalseCombining AND and OR operators without parentheses always results in incorrect queries.
While it may result in unexpected behavior, it does not always lead to incorrect queries. Understanding operator precedence is key.
Q11
True / FalseAND and OR operators can be used in a single query to filter data.
AND and OR operators can be combined in a single query to apply complex filtering conditions.
Q12
True / FalseThe AND operator can be used to return rows where all conditions are false.
The AND operator returns true only if all conditions are true, not false.
Q13
True / FalseThe OR operator can be used to return rows where all conditions are true.
The OR operator returns true if at least one of the conditions is true.
Q14
True / FalseCombining AND and OR operators requires careful attention to query logic.
Using both AND and OR in a query requires understanding how they interact to ensure correct logic.
Q15
True / FalseLogical operators like AND and OR are used in the WHERE clause to filter data.
AND and OR operators are typically used in the WHERE clause to apply conditions to filter rows in SQL queries.
Q19
Single ChoiceWhich query retrieves orders placed by customers with CustomerID 5 or who have ordered more than 10 items?
SQL Code
SELECT OrderID, CustomerID, Quantity
FROM Orders
WHERE CustomerID = 5
OR Quantity > 10;
The query uses the OR operator to return orders that meet either condition.
Q20
Single ChoiceWhich query retrieves products that are either in category 2 or have a price above 20?
SQL Code
SELECT ProductID, ProductName, Price
FROM Products
WHERE CategoryID = 2
OR Price > 20;
The query uses the OR operator to return products that meet either condition.
Q21
Single ChoiceWhich query retrieves customers who are either from city 'New York' or have a balance above 1000?
SQL Code
SELECT CustomerID, CustomerName, Balance
FROM Customers
WHERE City = 'New York'
OR Balance > 1000;
The query uses the OR operator to return customers who meet either condition.
Q22
Single ChoiceWhich query retrieves employees who are both in department 4 and have been hired after '2020-01-01'?
SQL Code
SELECT EmployeeID, EmployeeName, HireDate
FROM Employees
WHERE DepartmentID = 4
AND HireDate > '2020-01-01';
The query uses the AND operator to return employees who meet both conditions.
Q23
Single ChoiceWhich query retrieves orders placed by customer 3 and have a total amount greater than 500?
SQL Code
SELECT OrderID, CustomerID, TotalAmount
FROM Orders
WHERE CustomerID = 3
AND TotalAmount > 500;
The query uses the AND operator to return orders that meet both conditions.
Q24
Single ChoiceWhich query retrieves products that are both in category 1 and have a stock quantity below 50?
SQL Code
SELECT ProductID, ProductName, StockQuantity
FROM Products
WHERE CategoryID = 1
AND StockQuantity < 50;
The query uses the AND operator to return products that meet both conditions.
Q25
Single ChoiceWhich query retrieves customers who are from city 'Los Angeles' and have a balance above 500?
SQL Code
SELECT CustomerID, CustomerName, Balance
FROM Customers
WHERE City = 'Los Angeles'
AND Balance > 500;
The query uses the AND operator to return customers who meet both conditions.
Q26
Single ChoiceWhich query retrieves orders that were placed in 2021 or have a total amount above 1000?
SQL Code
SELECT OrderID, OrderDate, TotalAmount
FROM Orders
WHERE YEAR(OrderDate) = 2021
OR TotalAmount > 1000;
The query uses the OR operator to return orders that meet either condition.
Q27
Single ChoiceWhich query retrieves products that are either in category 3 or have a price below 10?
SQL Code
SELECT ProductID, ProductName, Price
FROM Products
WHERE CategoryID = 3
OR Price < 10;
The query uses the OR operator to return products that meet either condition.
Q28
Single ChoiceWhich query retrieves employees who are either in department 2 or have been hired before '2019-01-01'?
SQL Code
SELECT EmployeeID, EmployeeName, HireDate
FROM Employees
WHERE DepartmentID = 2
OR HireDate < '2019-01-01';
The query uses the OR operator to return employees who meet either condition.
Q29
Single ChoiceWhich query retrieves orders that were placed in the first quarter of 2021 and have a total amount below 500?
SQL Code
SELECT OrderID, OrderDate, TotalAmount
FROM Orders
WHERE YEAR(OrderDate) = 2021
AND MONTH(OrderDate) IN (1, 2, 3)
AND TotalAmount < 500;
The query uses the AND operator to return orders that meet all specified conditions.
Q30
Single ChoiceWhich query retrieves products that are either in category 4 or have been discontinued?
SQL Code
SELECT ProductID, ProductName, Discontinued
FROM Products
WHERE CategoryID = 4
OR Discontinued = 1;
The query uses the OR operator to return products that meet either condition.
Q31
Multiple ChoiceWhich query retrieves employees who are either in department 1 or 2 and have a salary above 3000?
SQL Code
SELECT EmployeeID, EmployeeName, Salary
FROM Employees
WHERE (DepartmentID = 1
OR DepartmentID = 2)
AND Salary > 3000;
The query uses both AND and OR operators to return employees who meet the specified conditions.
Q32
Multiple ChoiceWhich query retrieves products that are either in category 5 or have a stock quantity below 20 and a price above 10?
SQL Code
SELECT ProductID, ProductName, StockQuantity, Price
FROM Products
WHERE (CategoryID = 5
OR StockQuantity < 20)
AND Price > 10;
The query uses both AND and OR operators to return products that meet the specified conditions.
Q33
Multiple ChoiceWhich query retrieves customers who are either from 'Chicago' or 'Boston' and have made more than 5 purchases?
SQL Code
SELECT CustomerID, CustomerName, Purchases
FROM Customers
WHERE (City = 'Chicago'
OR City = 'Boston')
AND Purchases > 5;
The query uses both AND and OR operators to return customers who meet the specified conditions.
Q34
Multiple ChoiceWhich query retrieves orders placed by customers with CustomerID 4 or 7 and have a total amount below 200?
SQL Code
SELECT OrderID, CustomerID, TotalAmount
FROM Orders
WHERE (CustomerID = 4
OR CustomerID = 7)
AND TotalAmount < 200;
The query uses both AND and OR operators to return orders that meet the specified conditions.
Q35
Multiple ChoiceWhich query retrieves employees who have either joined in 2020 or 2021 and have a salary above 4000?
SQL Code
SELECT EmployeeID, EmployeeName, HireDate, Salary
FROM Employees
WHERE (YEAR(HireDate) = 2020
OR YEAR(HireDate) = 2021)
AND Salary > 4000;
The query uses both AND and OR operators to return employees who meet the specified conditions.
Q36
Multiple ChoiceWhich query retrieves products that are either in category 1 or 2 and have a price between 50 and 100?
SQL Code
SELECT ProductID, ProductName, Price
FROM Products
WHERE (CategoryID = 1
OR CategoryID = 2)
AND Price BETWEEN 50 AND 100;
The query uses both AND and OR operators to return products that meet the specified conditions.
Q37
Multiple ChoiceWhich query retrieves customers who are either from 'New York' or 'Los Angeles' and have made more than 3 purchases?
SQL Code
SELECT CustomerID, CustomerName, Purchases
FROM Customers
WHERE (City = 'New York'
OR City = 'Los Angeles')
AND Purchases > 3;
The query uses both AND and OR operators to return customers who meet the specified conditions.
Q38
Multiple ChoiceWhich query retrieves orders that were placed by customers with CustomerID 8 or 10 and have a total amount above 150?
SQL Code
SELECT OrderID, CustomerID, TotalAmount
FROM Orders
WHERE (CustomerID = 8
OR CustomerID = 10)
AND TotalAmount > 150;
The query uses both AND and OR operators to return orders that meet the specified conditions.
Q39
Multiple ChoiceWhich query retrieves employees who are either in department 3 or 4 and have been hired after '2020-01-01'?
SQL Code
SELECT EmployeeID, EmployeeName, HireDate
FROM Employees
WHERE (DepartmentID = 3
OR DepartmentID = 4)
AND HireDate > '2020-01-01';
The query uses both AND and OR operators to return employees who meet the specified conditions.
Q40
Multiple ChoiceWhich query retrieves products that are either in category 3 or 6 and have a stock quantity above 50?
SQL Code
SELECT ProductID, ProductName, StockQuantity
FROM Products
WHERE (CategoryID = 3
OR CategoryID = 6)
AND StockQuantity > 50;
The query uses both AND and OR operators to return products that meet the specified conditions.
Q41
Multiple ChoiceWhich query retrieves customers who have either made 10 or more purchases or have a loyalty score above 80?
SQL Code
SELECT CustomerID, CustomerName, Purchases, LoyaltyScore
FROM Customers
WHERE Purchases >= 10
OR LoyaltyScore > 80;
The query uses the OR operator to return customers who meet either condition.
Q42
Multiple ChoiceWhich query retrieves orders that have a discount above 20% or were placed in the last quarter of 2022?
SQL Code
SELECT OrderID, Discount, OrderDate
FROM Orders
WHERE Discount > 0.20
OR (YEAR(OrderDate) = 2022
AND MONTH(OrderDate) IN (10, 11, 12));
The query uses both AND and OR operators to return orders that meet the specified conditions.
Q43
Multiple ChoiceWhich query retrieves employees who are either managers or have been with the company for more than 5 years?
SQL Code
SELECT EmployeeID, EmployeeName, Position, HireDate
FROM Employees
WHERE Position = 'Manager'
OR DATEDIFF(YEAR, HireDate, GETDATE()) > 5;
The query uses the OR operator to return employees who meet either condition.
Q44
Multiple ChoiceWhich query retrieves products that are either discontinued or have a price less than 20?
SQL Code
SELECT ProductID, ProductName, Price, Discontinued
FROM Products
WHERE Discontinued = 1
OR Price < 20;
The query uses the OR operator to return products that meet either condition.
Q45
Multiple ChoiceWhich query retrieves employees who are either in the Sales department or the Marketing department and have a performance rating above 4?
SQL Code
SELECT EmployeeID, EmployeeName, DepartmentID, PerformanceRating
FROM Employees
WHERE (DepartmentID = 'Sales'
OR DepartmentID = 'Marketing')
AND PerformanceRating > 4;
The query uses both AND and OR operators to return employees who meet the specified conditions.