Microsoft SQL Server Database Quiz Questions

Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:AND and OR Operators
Current Quiz Count:45
Progress
0%
Q1
True / False

The AND operator returns true if both conditions are true.

Q2
True / False

The OR operator returns true if at least one condition is true.

Q3
True / False

The AND operator can be used to combine more than two conditions.

Q4
True / False

The OR operator can only combine two conditions at a time.

Q5
True / False

Combining conditions with AND always returns fewer rows than using OR.

Q6
True / False

The AND operator can be used to filter rows based on multiple columns.

Q7
True / False

The OR operator can be used to check multiple columns for NULL values.

Q8
True / False

The AND operator has higher precedence than the OR operator in SQL Server.

Q9
True / False

Using parentheses can change the order of evaluation for AND and OR operators.

Q10
True / False

Combining AND and OR operators without parentheses always results in incorrect queries.

Q11
True / False

AND and OR operators can be used in a single query to filter data.

Q12
True / False

The AND operator can be used to return rows where all conditions are false.

Q13
True / False

The OR operator can be used to return rows where all conditions are true.

Q14
True / False

Combining AND and OR operators requires careful attention to query logic.

Q15
True / False

Logical operators like AND and OR are used in the WHERE clause to filter data.

Q16
Single Choice

Which operator would you use to return rows that meet both of two conditions?

Q17
Single Choice

Which operator would you use to return rows that meet at least one of two conditions?

Q18
Single Choice

Which query retrieves employees who either work in department 3 or have a salary above 50000?

SQL Code
SELECT EmployeeID, EmployeeName
FROM Employees
WHERE DepartmentID = 3
OR Salary > 50000;
Q19
Single Choice

Which 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;
Q20
Single Choice

Which 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;
Q21
Single Choice

Which 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;
Q22
Single Choice

Which 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';
Q23
Single Choice

Which 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;
Q24
Single Choice

Which 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;
Q25
Single Choice

Which 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;
Q26
Single Choice

Which 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;
Q27
Single Choice

Which 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;
Q28
Single Choice

Which 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';
Q29
Single Choice

Which 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;
Q30
Single Choice

Which 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;
Q31
Multiple Choice

Which 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;
Q32
Multiple Choice

Which 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;
Q33
Multiple Choice

Which 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;
Q34
Multiple Choice

Which 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;
Q35
Multiple Choice

Which 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;
Q36
Multiple Choice

Which 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;
Q37
Multiple Choice

Which 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;
Q38
Multiple Choice

Which 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;
Q39
Multiple Choice

Which 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';
Q40
Multiple Choice

Which 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;
Q41
Multiple Choice

Which 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;
Q42
Multiple Choice

Which 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));
Q43
Multiple Choice

Which 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;
Q44
Multiple Choice

Which 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;
Q45
Multiple Choice

Which 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;