Assignment Questions
Assignment Questions
1. Write a query to select orchestras with a city of origin where a concert was held in
2013
2. Write a SQL query to find those employees whose salary matches the lowest salary of
any of the departments. Return first name, last name and department ID.
3. Write a SQL query to find those employees who earn more than the average salary.
Return employee ID, first name, last name.
4. Write a SQL query to find all those departments where at least one employee is
employed. Return department name
5. Write a SQL query to find employees who work in departments located in the United
Kingdom. Return first name
6. Write a SQL query to find out which employees are earning more than the average
salary and who work in any of the IT departments
7. Write a SQL query to find those employees who are managers. Return all the fields of
employees table.
8. Write a SQL query to find those employees who manage a department. Return all the
fields of employees table
9. Write a SQL query to find those employees whose salary matches that of the
employee who works in department ID 40. Return first name, last name, salary, and
department ID.
10. Write a SQL query to find those employees who earn less than the average salary and
work at the department where Laura (first name) is employed. Return first name, last
name, salary, and department ID.
GROUP QUESTIONS
11. In a university database, there are three tables: Students, Departments, and Courses.
The Students table contains information about students, including their StudentID,
Name, and DepartmentID. The Departments table stores department details with
columns DepartmentID and DepartmentName. The Courses table contains the list of
courses offered by each department, with columns CourseID, CourseName, and
DepartmentID. Write a query to find the names of students who belong to the
department that offers the fewest courses
12. In a sales database, there are three tables: Products, Categories, and Sales. The
Products table contains details about products, including ProductID, ProductName,
and CategoryID. The Categories table stores information about product categories
with columns CategoryID and CategoryName. The Sales table records the sales
transactions with columns SaleID, ProductID, and SaleAmount. Write a query to find
the names of products that belong to categories where the total sales amount exceeds
the average total sales amount across all categories.