You are on page 1of 3

ALBANERO Data Analyst PRE INTERVIEW ASSIGNMENT

(Type the query and attach the screenshot of output)

P1: Write an SQL query to find missing ids from a database


The missing ID’s are the ID’s that that fall in range of minimum and maximum of ids currently
present in the database
The ID’s cannot be more than 2 digits

ID Name

24 ABCD

27 DEFG

31 HIJKL

Expected output:

Missing ID

25

26

28

29

30

Please go through the following tables for answering the next 3 questions(P2- P4):

Employee Info Table:


EmpID EmpFname EmpLname Department Project Address DOB Gender
1 Sanjay Mehra HR P1 Hyderabad(HYD) 01/12/1976 M
2 Ananya Mishra Admin P2 Delhi(DEL) 02/05/1968 F
3 Rohan Diwan Account P3 Mumbai(BOM) 01/01/1980 M
4 Sonia Kulkarni HR P1 Hyderabad(HYD) 02/05/1992 F
5 Ankit Kapoor Admin P2 Delhi(DEL) 03/07/1994 M
Employee Position Table:
EmpID EmpPosition DateOfJoining Salary
1 Manager 01/05/2022 500000
2 Executive 02/05/2022 75000
3 Manager 01/05/2022 90000
2 Lead 02/05/2022 85000
1 Executive 01/05/2022 300000

P2: Write a query to retrieve Departments who have less than 2 employees working in it.
P3: Write a query to retrieve EmpPostion along with total salaries paid for each of them.
P4: Write a query to find the 3rd highest salary from the Employee Position table without using
TOP/limit keyword.

P5: Write a SQL query to find the median salary of each company without using any built-in
SQL functions
Id Company Salary
1 A 2341
2 A 341
3 A 15
4 A 15314
5 A 451
6 A 513
7 B 15
8 B 13
9 B 1154
10 B 1345
11 B 1221
12 B 234
13 C 2345
14 C 2645
15 C 2645
16 C 2652
17 C 65
Expected Output:

Id Company Salary
5 A 451
6 A 513
12 B 234
9 B 1154
14 C 2645

You might also like