Which SQL statement is used to retrieve data from a database?
Consider the following table structure:
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DepartmentID INT
);
What will be the result of executing the following SQL statement?
SELECT COUNT(*) FROM Employees;
Consider the following table structure:
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
City VARCHAR(50)
);
What will be the result of executing the following SQL statement?
SELECT FirstName, LastName FROM Customers WHERE City = 'New York';
Consider the following table structure:
CREATE TABLE Products (
ProductID INT PRIMARY KEY,
ProductName VARCHAR(50),
UnitPrice DECIMAL(10, 2),
UnitsInStock INT
);
What will be the result of executing the following SQL statement?
SELECT AVG(UnitPrice) FROM Products;
Consider the following table structure:
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
OrderDate DATE,
TotalAmount DECIMAL(10, 2),
CustomerID INT
);
What will be the result of executing the following SQL statement?
SELECT MAX(TotalAmount) FROM Orders WHERE OrderDate > '2022-01-01';
Consider the following table structure:
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DepartmentID INT
);
What will be the result of executing the following SQL statement?
SELECT LastName, FirstName FROM Employees ORDER BY LastName ASC, FirstName DESC;
Consider the following table structure:
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
StudentName VARCHAR(50),
CourseID INT,
Grade VARCHAR(2)
);
Which of the following SQL statements will return the number of students enrolled in each course along with the course ID?
Consider the following table structure:
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DepartmentID INT
);
Which of the following SQL statements will return the employees who belong to the departments with the highest number of employees?
Consider the following table structure:
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
OrderDate DATE,
TotalAmount DECIMAL(10, 2),
CustomerID INT
);
Which of the following SQL statements will return the customer ID(s) with the highest total amount spent on orders?
Consider the following table structure:
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DepartmentID INT
);
Which of the following SQL statements will return the number of employees in each department along with the department name?
Consider the following table structure:
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
OrderDate DATE,
TotalAmount DECIMAL(10, 2),
CustomerID INT
);
Which of the following SQL statements will return the average total amount spent on orders for each year?