SQL Queries
SQL Queries
Write a SQL query to retrieve all employees from the "Employees" table who are in the "Marketing" department.
Answer:
Question:
Write a SQL query to calculate the total number of orders placed in the "Orders" table.
Answer:
Question:
Write a SQL query to update the salary of an employee with the ID 101 to $5000.
Answer:
Question:
Write a SQL query to delete all orders placed before January 1, 2022, from the "Orders" table.
Answer:
Question:
Write a SQL query to insert a new record into the "Customers" table with the following details: CustomerID = 101, Name = 'John Smith', and City
= 'New York'.
Answer:
INSERT INTO Customers (CustomerID, Name, City) VALUES (101, 'John Smith', 'New York');
Question:
Write a SQL query to retrieve the highest salary among all employees.
Answer:
Question:
Write a SQL query to retrieve the names of all products in the "Products" table sorted in ascending order of their prices.
Answer:
Question:
Write a SQL query to retrieve the names of all employees along with their corresponding department names.
Answer:
SELECT e.Name AS EmployeeName, d.Name AS DepartmentName FROM Employees e INNER JOIN Departments d ON e.DepartmentID =
d.DepartmentID;