Top 10 Scenario based SQL Interview Questions @testerhoon28
Q1 -Employees table has employee IDs as well as manager IDs, Can you display employee names
with their reporting manager name.
Answer: We use Self Join concept to derive the outcome
Syntax: Select E1.Empname, E2.Empname as Mgrname from Employees E1 Join Employees E2
ONE1.MgrID= E2.empID;
Q2 - There are 1000 records in the source and loaded only 999 records into the target, How can we know which record is missing without using Minus Query
Answer: We can use Left Join to find the missing record.
Source Table Join with Target table, all the matched records will be populated and non
matching record from left table will be updated as null
select e.employee_id as src_employee_id, e.first_name as src_FirstName,
t.employee_id as trg_employee_id, t.first_name as trg_first_name
from employees e left join t_employees t on e.employee_id = t.employee_id
where t.employee_id is null
Q3 - Table A and Table B has deptno. Can you find which deptno is not in table A which exists in table
B?
Answer: Right Join with where condition on null check
For Full List of Questions, Please do visit
www.testerhoon...
Негізгі бет Top 10 SQL Interview Questions on Scenario based
Пікірлер: 11