0% found this document useful (0 votes)
31 views1 page

Practical Assignment1 - SQL Queries

The document provides SQL queries to answer 5 questions about employees and departments from database tables: 1. Counts employees working in Delhi or Noida. 2. Names employees working in Marketing. 3. Finds employees with salary over Rs.12500. 4. Shows employees joined in the last week by date of joining. 5. Finds employees in HR, joined last week with salary over Rs.15000.

Uploaded by

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

Practical Assignment1 - SQL Queries

The document provides SQL queries to answer 5 questions about employees and departments from database tables: 1. Counts employees working in Delhi or Noida. 2. Names employees working in Marketing. 3. Finds employees with salary over Rs.12500. 4. Shows employees joined in the last week by date of joining. 5. Finds employees in HR, joined last week with salary over Rs.15000.

Uploaded by

pratikshyamishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Find out the following and generate SQL related to the queries

1. How many employees are working in (Noida, Delhi)

SELECT Count(Emp.EmpID) AS CountOfEmpID, Dept.Location


FROM Dept INNER JOIN Emp ON Dept.DeptID = Emp.DeptID
GROUP BY Dept.Location
HAVING (((Dept.Location)="Delhi" Or (Dept.Location)="Noida"));

2. Name the employees working in Marketing

SELECT Emp.EmpName
FROM Dept INNER JOIN Emp ON Dept.DeptID = Emp.DeptID
WHERE (((Dept.DeptName)="Marketing"))
GROUP BY Emp.EmpName;

3. Find out the employees getting salary more than Rs.12500

SELECT Emp.EmpID, Emp.EmpName, Emp.Salary


FROM Dept INNER JOIN Emp ON Dept.DeptID = Emp.DeptID
WHERE (((Emp.Salary)>=12500))
GROUP BY Emp.EmpID, Emp.EmpName, Emp.Salary;

4. Show the employees joined in last week from latest DOJ

SELECT Emp.EmpID, Emp.EmpName, Emp.DOJ


FROM Dept INNER JOIN Emp ON Dept.DeptID = Emp.DeptID
WHERE (((Emp.DOJ) Between (Select TOP 1 percent Emp.DOJ from Emp order by Emp.DOJ desc)
And ((Select TOP 1 percent Emp.DOJ from Emp order by Emp.DOJ desc)-7)))
GROUP BY Emp.EmpID, Emp.EmpName, Emp.DOJ;

5. Find the employees working in HR, joined last week and having salary more than Rs.15000

SELECT Emp.EmpID, Emp.EmpName, Emp.Salary, Emp.DOJ


FROM Dept INNER JOIN Emp ON Dept.DeptID = Emp.DeptID
WHERE (((Dept.DeptName)="HR") AND ((Emp.Salary)>15000) AND ((Emp.DOJ) Between Date()
And Date()-7))
GROUP BY Emp.EmpID, Emp.EmpName, Emp.Salary, Emp.DOJ;

You might also like