0% found this document useful (0 votes)
8 views9 pages

ETL Testing Interview Questions

Uploaded by

anuradha.u08
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)
8 views9 pages

ETL Testing Interview Questions

Uploaded by

anuradha.u08
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/ 9

ETL Testing

Interview Questions
1.Get the output using Inner Join, Left Outer Join, Right Outer Join,
Full Outer Join?
Table-1 Table-2
ID ID
1 1
2 2
1 4
2 0
3 NULL
0 NULL
NULL
NULL

Inner Join: This join select all rows of both the tables as long as condition
satisfied.
ID ID_1
1 1
2 2
1 1
2 2
0 0

Left Outer Join: This join returns all the rows of the table on the left side and
mathes rows of the table on the right side.
ID ID
1 1
2 2
1 1
2 2
0 0
Null null
Null null
3 null

Right Outer Join: This join returns all the rows of the table on the right side and
mathes rows of the table on the left side.
ETL Testing
Interview Questions
ID ID
1 1
2 2
1 1
2 2
0 0
Null null
Null null
Null 4

Full Outer Join: This join returns all the rows of both LEFT and RIGHT tables.
ID ID
1 1
2 2
1 1
2 2
0 0
Null null
Null null
Null 4
3 null
Null null
Null null

2.How to identify duplicate records from a table?


select id, count(*) from table_1 group by id having count(id)>1;

3. Fetch domain name and name from email?


select substr(email, instr(email,'@',1)+1) as Domain Name from employees;
select substr(email,1,instr(email,'@',1)-1) as Name from employees ;
4.Write down the query to find out the nth Highest Salary?
select * from (select employee_id,salary,dense_rank() over(order by salary
desc) as d from employees) where d=1;
5.Write down the query to find out the nth Highest Salary?
select * from (select employee_id,salary,dense_rank() over(order by salary ) as
d from employees) where d=1;
ETL Testing
Interview Questions
6.What is the output for below query?
Insert 10 records;
Rollback;
Delete 10 records;
Insert 10 records;
Commit;
Rollback;
What is the output of above queries?
10 records available

7.Fetch the second character ‘A’. Write SQL for it?


Select first_name from employees where lower(first_name) like ‘_a%’;

8.Explain query execution flow in SQL;


o From
o Where
o Group by
o Having
o Select
o Order by
9.What is the difference between UNION and UNION ALL?
UNION: The union clause is used to combine two select statements and
produce the result set as a union of both the select statements. Union contains
some set of rules.
1.The fields to be used in select statements must be in same order, same
number and same datatype.
2. The union produces distinct values in the result set.
UNION ALL: Same as union clause but it fetch the duplicate values too.

10.Write the sql query to fetch department wise nth lowest salary?
ETL Testing
Interview Questions
select * from (select employee_id,department_id,salary,dense_rank()
over(partition by department_id order by salary asc) as derank from
employees) where derank=1;
11.Write down the SQL query to get second maximum and maximum
salary from employee table?
Select max(salary) from employees;
select max(salary) from employees where salary not in(select max(salary) from
employees);
12.Fetch the employees more than 1 year experience?
Select employee_id, first_name, salary ,hire_date,(extract(year from sysdate)-
extract(year from hire_date)) as exp from employees where extract(year from
sysdate)-extract(year from hire_date)>1;
13.Fetch the dept name which is not having single employee?
select department_id,department_name from departments d where
department_id not in(select distinct nvl(department_id,0) from employees );
14. What is the difference between RANK() VS DENSE_RANK() VS
ROW_NUMBER()?
RANK(): Rank will assign the same number for the row which contains the same
value and skips next number.
Dense_rank(): dense_rank() will assign the same number for the row which
contains the same value and with out skipping the next number.
Row_number(): row_number() will generate a unique number for every
row ,even if one or more rows has the same value.

15.write down the query to find the greatest value from below
columns?
Year Q1 Q2 Q3 Q4
2019 100 200 300 400
2020 600 100 200 300
2021 100 700 200 NULL

Select year, greatest(Q1,Q2,Q3,Q4) as year of sales from sales;

16.Fetch the EVEN and ODD records from the table?


ETL Testing
Interview Questions
EVEN Records:
select * from (select rownum as rn,employee_id,first_name,salary from
employees) where mod(rn,2)=0;
ODD Records:
select * from (select rownum as rn,employee_id,first_name,salary from
employees) where mod(rn,2)=1;
17.Update multiple records at a time?
update departments set department_name=case
when department_id=90 then 'Ex'
when department_id=80 then 'sa'
end;

18.Write sql query to find rows that occurs only once?


select count(*),id from table_1 group by id having count(*)=1;

19.Difference between DROP,DELETE,TRUNCATE?


DROP DELETE TRUNCATE
It is a DDL command It is a DML command It is a DDL command
Delete the rows at
Delete the rows at table level specific record using Delete the data at table level
and metadata as well where ondition not metadata
Delete can be rollback
Drop cannot be rollback but using ROLLBACK Truncate cannot be rollbck and
can be flashback the table command cannot be flashback the table

20.Difference between PRIMARY KEY and UNIQUE KEY?


PRIMARY KEY UNIQUE KEY
It serves as a unique record It serves as a unique record
in the table in the table
Cannot accept null values Can accept null values
Single primary key allowed in No of unique keys are
the table allowed
Unique key does not
Primary key support auto support auto increment
increment values values
Cannot change primary key Can change unique key
values values

21.Difference between PRIMARY KEY and FOREIGN KEY?


ETL Testing
Interview Questions
PRIMARY KEY FOREIGN KEY
It create
relationship
between 2 tables
and it will refer
It maintain the another table
record is unique primary key
It will not allow duplicates It will allow duplicates
It will not allow null values It will allow null values
Only one primary key can be No of foreign keys allowed
allowed in a table for a single table
Its value cannot be deleted Its value can be deleted
from the parent table from the child table

22.Write query department wise highest salary along with


department name?

WITH MAX FUNCTION::


select d.department_name,max(e.salary) from employees e
join
departments d on e.department_id=d.department_id group by
d.department_name;

WITH INLINE VIEWS::

select employee_id,department_name,salary from (select


employee_id,department_id,salary from (select
employee_id,department_id,salary,
dense_rank() over(partition by department_id order by salary desc)max_salary
from employees)a where max_salary=1)ab
inner join
departments d on d.department_id=ab.department_id;

23. Find second minimum and maximum salary?


ETL Testing
Interview Questions
WITH MAX,MIN FUNCTIONS:
select max(salary) as max_salary from employees where salary not in(select
max(salary) from employees);
select min(salary) as min_salary from employees where salary not in(select
min(salary) from employees);

WITH DENSE_RANK FUNCTION::


select distinct salary as max_salary from (select salary,dense_rank() over(order
by salary desc ) max_salary from employees)a where max_salary=2;
select distinct salary as min_salary from (select salary,dense_rank() over(order
by salary) min_salary from employees)a where min_salary=2;

24.Fetch day wise total salaries?

Select extract(day from created_date) as day,sum(salary) as total_salary from


table_1 group by extract(day from created_date);

25.Fetch domain name from email without .com?


select substr(domain,1,instr(domain,'.',1)-1) from (select
substr('[email protected]',instr('[email protected]','@',1)+1) domain
from dual)a;
26.Write down the sqlquery to form a full name from columns?

Select employee_id,(case
when first_name is not null and middle_name is not null and last_name is not
null then first_name||’_’||middle_name||’_’||last_name
when first_name is null and middle_name is null and last_name is not null
then last_name
when first_name is null and middle_name is not null and last_name is not null
then middle_name||’_’||last_name
when first_name is not null and middle_name is not null and last_name is null
then first_name||’_’|| middle_name
when first_name is not null and middle_name is null and last_name is null
then first_name
when first_name is not null and middle_name is not null and last_name is null
then first_name||’_’||last_name
when first_name is null and middle_name not null and last_name is null
then middle_name
else “null”
ETL Testing
Interview Questions
end as fullname from employee;

27.Fetch TOP 2 salaries for each month?


select emp_id,salary,credit_date from (select
emp_id,salary,credit_date,dense_rank() over(partition by extract(month from
credit_date) order by salary desc) as monthwisesalary from salaries)sal where
monthwisesalary<=2 order by credit_date;

28.Fetch the EVEN and ODD records from the table?


EVEN Records:
select * from (select rownum as rn,employee_id,first_name,salary from
employees) where mod(rn,2)=0;
ODD Records:
select * from (select rownum as rn,employee_id,first_name,salary from
employees) where mod(rn,2)=1;
29.Remove duplicate records form table?
SELECT * FROM VALUESCOUNT
WHERE rowid not in
(
SELECT NAME,MAX(rowid)
FROM VALUESCOUNT
GROUP BY NAME
);
30.SQL Query to get Positive Numbers Total & Negative Numbers
Total in a single line query ?
select sum( case when name>0 then name else 0 end ) as
positivenumcount,sum( case when name<0 then name else 0 end ) as
negativenumcount from valuescount;

31.Write down the SQL Query for fetching manager details who is
having more than 10 subordinates?

select * from employees where employee_id in(Select manager_id from


employees group by manager_id having count(*)>10);
ETL Testing
Interview Questions

You might also like