0% found this document useful (0 votes)
8 views2 pages

SQL Employee Table Assignment Guide

The document outlines an SQL assignment involving an Employee Table with various attributes such as EmpID, FirstName, LastName, Department, Salary, and HireDate. It includes a series of queries to be executed on the table, such as displaying all employee data, filtering by department, salary, and hire date, as well as calculating averages and counting employees in departments. The assignment emphasizes practical SQL skills for data retrieval and manipulation.

Uploaded by

2002bhoopesh2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

SQL Employee Table Assignment Guide

The document outlines an SQL assignment involving an Employee Table with various attributes such as EmpID, FirstName, LastName, Department, Salary, and HireDate. It includes a series of queries to be executed on the table, such as displaying all employee data, filtering by department, salary, and hire date, as well as calculating averages and counting employees in departments. The assignment emphasizes practical SQL skills for data retrieval and manipulation.

Uploaded by

2002bhoopesh2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL (Assignment)

Employee Table
EmpID FirstName LastName Department Salary HireDate

101 Alice Johnson IT 6500 20200315

102 Mark Rivera HR 4800 20190722

103 Sophia Lee Finance 7200 20210110

104 Daniel Kim IT 5800 20181105

105 Emma Brown Marketing 5300 20220418

106 Liam Patel Finance 6900 20200929

107 Olivia Garcia HR 4600 20170630

108 Noah Thompson IT 7500 20230212

109 Ava Martinez Marketing 5100 20191202

110 Ethan Davis Finance 8000 20160514

Create the above Table in MySQL and solve the following problems based on it.

Assignment Problems
Q1. Write a query to display every employee and all their data.

Q2. List only the FirstName, LastName, and Salary of every employee.

Q3. Show all employees who work in the 'IT' department.

Q4. Retrieve employees with a salary greater than 6000.

Q5. List all employees ordered by HireDate from newest to oldest.

Q6. Show a list of all unique departments present in the table.

Q7. Find employees whose first name starts with ‘Aʼ.

Q8. Show employees whose salaries are between 4000 and 7000.

Q9. Find the average salary of all employees.

SQL Assignment) 1
Q10. List each department along with the number of employees, but only include departments
with more than 3 employees.

SQL Assignment) 2

Common questions

Powered by AI

To find all employees working in the 'IT' department, you would use the query: `SELECT * FROM Employee WHERE Department = 'IT';` This query retrieves all columns for employees whose department field is 'IT' .

You can retrieve a list of unique departments by using the query: `SELECT DISTINCT Department FROM Employee;`. This will give you the following list of departments: IT, HR, Finance, and Marketing .

The query `SELECT FirstName, LastName, Salary FROM Employee WHERE HireDate > '2020-01-01';` lists names and salaries of employees hired after this date. Alice Johnson, Sophia Lee, Emma Brown, and Noah Thompson meet these conditions .

Adding a new employee with a salary higher than any current would increase the average salary. To calculate the new average, sum the existing salaries, add the new salary, and divide by the new employee count. For example, adding an employee with a 9000 salary, the average becomes ((6290 * 10) + 9000) / 11 = 6472.73 .

You can order employees by hiring date from newest to oldest with the query: `SELECT * FROM Employee ORDER BY HireDate DESC;`. This ordering shows the latest hiring was Noah Thompson and the earliest was Ethan Davis. This analysis could reveal hiring trends such as spikes or lulls in hiring activity over time .

Based on the employee table, the departments and their corresponding employee counts are: IT with 3 employees, HR with 2 employees, Finance with 3 employees, and Marketing with 2 employees. None of the departments have more than 3 employees, so no department would be included in a list that only considers departments with more than 3 employees .

Use the query: `SELECT * FROM Employee WHERE FirstName LIKE 'A%';`. This SQL operation filters employees whose first name starts with the letter 'A'. In this dataset, only Alice Johnson matches the criterion .

Employees with a salary greater than 6000 are Sophia Lee, Noah Thompson, Liam Patel, and Ethan Davis. This indicates that high salaries are more common in the Finance and IT departments .

To determine the average salary of employees, use the SQL query: `SELECT AVG(Salary) FROM Employee;`. This query calculates the average of all salary values. The average salary calculated from the provided data is 6290 .

To list employees with salaries between 4000 and 7000, use the query: `SELECT * FROM Employee WHERE Salary BETWEEN 4000 AND 7000;`. This query will include Alice Johnson, Mark Rivera, Daniel Kim, Emma Brown, Olivia Garcia, and Ava Martinez .

You might also like