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

SQL Queries for HR Analytics

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)
73 views1 page

SQL Queries for HR Analytics

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

Find out the following and generate SQL related to the queries

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

SELECT Count([Link]) AS CountOfEmpID, [Link]


FROM Dept INNER JOIN Emp ON [Link] = [Link]
GROUP BY [Link]
HAVING ((([Link])="Delhi" Or ([Link])="Noida"));

2. Name the employees working in Marketing

SELECT [Link]
FROM Dept INNER JOIN Emp ON [Link] = [Link]
WHERE ((([Link])="Marketing"))
GROUP BY [Link];

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

SELECT [Link], [Link], [Link]


FROM Dept INNER JOIN Emp ON [Link] = [Link]
WHERE ((([Link])>=12500))
GROUP BY [Link], [Link], [Link];

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

SELECT [Link], [Link], [Link]


FROM Dept INNER JOIN Emp ON [Link] = [Link]
WHERE ((([Link]) Between (Select TOP 1 percent [Link] from Emp order by [Link] desc)
And ((Select TOP 1 percent [Link] from Emp order by [Link] desc)-7)))
GROUP BY [Link], [Link], [Link];

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

SELECT [Link], [Link], [Link], [Link]


FROM Dept INNER JOIN Emp ON [Link] = [Link]
WHERE ((([Link])="HR") AND (([Link])>15000) AND (([Link]) Between Date()
And Date()-7))
GROUP BY [Link], [Link], [Link], [Link];

You might also like