Interview Questions
Interview Questions
The scope of this exercise is to provide a structure for the future technical discussion interview. In order
to proceed please read all required questions before starting this test.
Note that the test can be build using any Oracle Database as well as the Online version
https://livesql.oracle.com
You can test all your work there.
The submitted result should consist in a set of scripts, numbered by the question it will answer.
For example file “1. .sql” will represent your answer to the first question.
Contents
Overview ....................................................................................................................................................... 1
Problem Set 1 ............................................................................................................................................ 3
Problem Set 2 ............................................................................................................................................ 5
Problem Set 3 ............................................................................................................................................ 6
Problem Set 4 ............................................................................................................................................ 7
Problem Set 5 ............................................................................................................................................ 9
Annex .......................................................................................................................................................... 10
PS1 - Install.SQL....................................................................................................................................... 10
PS3 - Install.SQL....................................................................................................................................... 23
Problem Set 1
Run install script “PS1 – Install.SQL” from annex.
Using the generated file, please provide code to answer the following requirements:
2. Please provide the script to remove all the duplicate rows (only duplicates)
4. Please provide SQL to display the names of all employees whose salaries belong to GRADE 3.
5. Using the provided TST_EMP table, please provide a list of all employees and their current
total income (consider commission is provided as percentage of base salary).
7. Please write a query that would return the employees in the format from bellow output,
independently of the number of leafs the hierarchy might have
(please note the solution requires a hierarchical query)
------------------------------------------------------
KING
JONES
SCOTT
...
Problem Set 2
Using data set created on prior problem set, please have a look at the following piece of code:
declare
cursor c is
select * from employees
order by sal desc;
l c%rowtype;
begin
open c;
loop
fetch c into l;
exit when c%notfound;
update employees
set salary=salary*(1 +
(select ((avg_salary-salary)+5)/100
from
(select avg(salary) as avg_salary
from employees emp
join department dep
on emp.department_id=dep.row_id
group by dep.row_id
) s
where
s.department_id=employees.department_id
)
)
where emno=l.empno
;
commit;
end loop;
end;
/
1. Identify any mistakes in the following code (please include any logical as well as any design
mistakes).
2. Re-write the code in the most effective manner you envision
Problem Set 4
Considering the 2 tables created during Problem set 3:
a)
b)
c)
Problem Set 5
USAGE_LOG
--------------------------------------------------------
--------------------------------------------------------
( "EMPLOYEE_ID" NUMBER(6,0),
"HIRE_DATE" DATE,
"SALARY" NUMBER(8,2),
"COMMISSION_PCT" NUMBER(2,2),
"MANAGER_ID" NUMBER(6,0),
"DEPARTMENT_ID" NUMBER(4,0),
);
commit;
(GRADE number
, losal number
, hisal number)
;
insert into TST_SAL_RANGE
commit;
PS3 - Install.SQL
--------------------------------------------------------
--------------------------------------------------------
( "EMPLOYEE_ID" NUMBER(6,0),
"FIRST_NAME" VARCHAR2(20 ),
"LAST_NAME" VARCHAR2(25 ),
"EMAIL" VARCHAR2(25 ),
"PHONE_NUMBER" VARCHAR2(20 ),
"HIRE_DATE" DATE,
"JOB_ID" VARCHAR2(10 ),
"SALARY" NUMBER(8,2),
"COMMISSION_PCT" NUMBER(2,2),
"MANAGER_ID" NUMBER(6,0),
"DEPARTMENT_ID" NUMBER(4,0),
"RAISE" CHAR(1 )
);
commit;
( "DEPARTMENT_ID" NUMBER(4,0),
"DEPARTMENT_NAME" VARCHAR2(30 ),
"MANAGER_ID" NUMBER(6,0),
"LOCATION_ID" NUMBER(4,0)
);
commit;