Microsoft SQL Server Database Quiz Questions

Chapter Name:Chapter 7 - DQL (Data Query Language)
Current Quiz Count:45
Progress
0%
Q1
True / False

In SQL, the '>' operator is used to check if a value is greater than another value.

Q2
True / False

The '<' operator can be used to compare string values in SQL.

Q3
True / False

The '>' operator cannot be used with NULL values in SQL.

Q4
True / False

The '<' operator is used to check if a value is greater than or equal to another value.

Q5
True / False

Using the '>' operator with numeric values can result in logical errors if the values are negative.

Q6
True / False

The '>' operator is used to compare dates in SQL Server.

Q7
True / False

The '<' operator is used to compare two numeric values in SQL Server.

Q8
True / False

The '>' operator can be used to filter results in a SQL query based on a condition.

Q9
True / False

Using '<' with string values will compare their ASCII values in SQL Server.

Q10
True / False

In SQL Server, '<' can be used to compare two columns directly in the WHERE clause.

Q11
True / False

The '>' operator will return an error if used with different data types in SQL Server.

Q12
True / False

Using '<' to compare NULL values will always return true in SQL Server.

Q13
True / False

The '>' operator can be used in a JOIN condition in SQL Server.

Q14
True / False

Using '<' in the SELECT clause will cause an error in SQL Server.

Q15
True / False

The '>' operator cannot be used in a subquery condition in SQL Server.

Q16
Single Choice

Which query retrieves employees with salaries greater than 50000?

SQL Code
SELECT EmployeeID, EmployeeName, Salary
FROM Employees
WHERE Salary > 50000;
Q17
Single Choice

Which query retrieves products with prices less than 100?

SQL Code
SELECT ProductID, ProductName, Price
FROM Products
WHERE Price < 100;
Q18
Single Choice

Which query retrieves orders placed before the year 2022?

SQL Code
SELECT OrderID, OrderDate, CustomerID
FROM Orders
WHERE YEAR(OrderDate) < 2022;
Q19
Single Choice

Which query retrieves products with stock quantities greater than 50?

SQL Code
SELECT ProductID, ProductName, StockQuantity
FROM Products
WHERE StockQuantity > 50;
Q20
Single Choice

Which query retrieves employees who joined the company before the year 2015?

SQL Code
SELECT EmployeeID, EmployeeName, HireDate
FROM Employees
WHERE YEAR(HireDate) < 2015;
Q21
Single Choice

Which query retrieves orders with total amounts greater than 1000?

SQL Code
SELECT OrderID, OrderDate, TotalAmount
FROM Orders
WHERE TotalAmount > 1000;
Q22
Single Choice

Which query retrieves customers with ages less than 30?

SQL Code
SELECT CustomerID, CustomerName, Age
FROM Customers
WHERE Age < 30;
Q23
Single Choice

Which query retrieves products with weights less than 10?

SQL Code
SELECT ProductID, ProductName, Weight
FROM Products
WHERE Weight < 10;
Q24
Single Choice

Which query retrieves employees with performance ratings greater than 4?

SQL Code
SELECT EmployeeID, EmployeeName, PerformanceRating
FROM Employees
WHERE PerformanceRating > 4;
Q25
Single Choice

Which query retrieves orders placed after January 1, 2023?

SQL Code
SELECT OrderID, OrderDate, CustomerID
FROM Orders
WHERE OrderDate > '2023-01-01';
Q26
Single Choice

Which query retrieves employees with ages greater than 40?

SQL Code
SELECT EmployeeID, EmployeeName, Age
FROM Employees
WHERE Age > 40;
Q27
Single Choice

Which query retrieves products with quantities in stock less than 100?

SQL Code
SELECT ProductID, ProductName, QuantityInStock
FROM Products
WHERE QuantityInStock < 100;
Q28
Single Choice

Which query retrieves orders with total amounts less than 200?

SQL Code
SELECT OrderID, OrderDate, TotalAmount
FROM Orders
WHERE TotalAmount < 200;
Q29
Single Choice

Which query retrieves customers with credit limits greater than 5000?

SQL Code
SELECT CustomerID, CustomerName, CreditLimit
FROM Customers
WHERE CreditLimit > 5000;
Q30
Single Choice

Which query retrieves employees with experience less than 5 years?

SQL Code
SELECT EmployeeID, EmployeeName, Experience
FROM Employees
WHERE Experience < 5;
Q31
Multiple Choice

Which of the following queries retrieve products with prices greater than 50?

SQL Code
SELECT ProductID, ProductName, Price
FROM Products
WHERE Price > 50;
Q32
Multiple Choice

Which of the following queries retrieve employees with performance ratings less than 3?

SQL Code
SELECT EmployeeID, EmployeeName, PerformanceRating
FROM Employees
WHERE PerformanceRating < 3;
Q33
Multiple Choice

Which of the following queries retrieve orders with total amounts greater than 500?

SQL Code
SELECT OrderID, OrderDate, TotalAmount
FROM Orders
WHERE TotalAmount > 500;
Q34
Multiple Choice

Which of the following queries retrieve customers with ages greater than 25?

SQL Code
SELECT CustomerID, CustomerName, Age
FROM Customers
WHERE Age > 25;
Q35
Multiple Choice

Which of the following queries retrieve products with weights less than 20?

SQL Code
SELECT ProductID, ProductName, Weight
FROM Products
WHERE Weight < 20;
Q36
Multiple Choice

Which of the following queries retrieve employees with experience greater than 10 years?

SQL Code
SELECT EmployeeID, EmployeeName, Experience
FROM Employees
WHERE Experience > 10;
Q37
Multiple Choice

Which of the following queries retrieve orders placed before the year 2021?

SQL Code
SELECT OrderID, OrderDate, CustomerID
FROM Orders
WHERE YEAR(OrderDate) < 2021;
Q38
Multiple Choice

Which of the following queries retrieve customers with credit limits less than 3000?

SQL Code
SELECT CustomerID, CustomerName, CreditLimit
FROM Customers
WHERE CreditLimit < 3000;
Q39
Multiple Choice

Which of the following queries retrieve products with quantities in stock less than 500?

SQL Code
SELECT ProductID, ProductName, QuantityInStock
FROM Products
WHERE QuantityInStock < 500;
Q40
Multiple Choice

Which of the following queries retrieve employees with salaries greater than 80000?

SQL Code
SELECT EmployeeID, EmployeeName, Salary
FROM Employees
WHERE Salary > 80000;
Q41
Multiple Choice

Which of the following queries retrieve employees who have worked for the company for more than 10 years and have a salary greater than 90000?

SQL Code
SELECT EmployeeID, EmployeeName, HireDate, Salary
FROM Employees
WHERE DATEDIFF(year, HireDate, GETDATE()) > 10
AND Salary > 90000;
Q42
Multiple Choice

Which of the following queries retrieve products with prices between 200 and 800 and a stock quantity less than 100?

SQL Code
SELECT ProductID, ProductName, Price, QuantityInStock
FROM Products
WHERE Price > 200 AND Price < 800
AND QuantityInStock < 100;
Q43
Multiple Choice

Which of the following queries retrieve customers who have spent more than 5000 in the last 3 years and placed less than 10 orders?

SQL Code
SELECT CustomerID, CustomerName, COUNT(OrderID) as OrderCount, SUM(TotalAmount) as TotalSpent
FROM Orders
WHERE OrderDate > DATEADD(year, -3, GETDATE())
GROUP BY CustomerID, CustomerName
HAVING SUM(TotalAmount) > 5000
AND COUNT(OrderID) < 10;
Q44
Multiple Choice

Which of the following queries retrieve employees in the IT department with experience greater than 8 years and a salary less than 85000?

SQL Code
SELECT EmployeeID, EmployeeName, Department, DATEDIFF(year, HireDate, GETDATE()) as Experience, Salary
FROM Employees
WHERE Department = 'IT'
AND DATEDIFF(year, HireDate, GETDATE()) > 8
AND Salary < 85000;
Q45
Multiple Choice

Which of the following queries retrieve orders placed in the last 6 months with total amounts greater than 1500 and containing more than 5 items?

SQL Code
SELECT OrderID, OrderDate, TotalAmount, ItemCount
FROM Orders
WHERE OrderDate > DATEADD(month, -6, GETDATE())
AND TotalAmount > 1500
AND ItemCount > 5;