SQL Interview Questions | Collect employee details
Question
empid | empname | managerid | deptid | Salary |
1 | Emp1 | 0 | 1 | 6000 |
2 | Emp2 | 0 | 5 | 6000 |
3 | Emp3 | 1 | 1 | 2000 |
13 | Emp13 | 2 | 5 | 2000 |
11 | Emp11 | 2 | 1 | 2000 |
9 | Emp9 | 1 | 5 | 3000 |
8 | Emp8 | 3 | 1 | 3500 |
7 | Emp7 | 2 | 5 | NULL |
3 | Emp3 | 1 | 1 | 2000 |
Can you get employee details whose department id is not valid or department id not present in the department table?
in progress
0
SQL
55 years
4 Answers
940 views
Great Grand Master 0
Answers ( 4 )
select * from Emp where deptid
NOT IN (select deptid from Dept)
select * from emp where deptid not in (select deptid from department);
select *from employee
where deptid NOT IN ( Select Dept Id from Department Table)
select * from employees where dept_id is null;