You are on page 1of 6

1) Choose the right query for getting the last n records from a given employee table

A) select * from emp minus select * from emp where rownum <= (select * - &n from
emp);

B) select * from emp - select * from emp where rownum <= (select count(*) - n from

emp);

C) select * from emp minus select * from emp where rownum <= n ;
D) select * from emp minus select * from emp where rownum <= (select count(*) - &n
from emp);
E) select * from emp minus select * from emp where rownum <= (select count(*) - n
from emp);
2) Choose the riht query for deleting the duplicate rows from a table
A) delete from emp a where rowid != (select rowid from emp b where
a.empno=b.empno);
B) delete from emp a where rowid not in (select rowid from emp b where
a.empno=b.empno);
C) delete from emp a where rowid != (select max(rowid) from emp b where
a.empno=b.empno);
D) delete from emp a where rownum != (select max(rowid) from emp b where
a.empno=b.empno);
E) delete from emp a where rownum <> (select max(rowid) from emp b where
a.empno=b.empno);
3) Choose the right query for finding the 3rd MIN salary in the emp table.
A) select distinct sal from emp e1 where 3 = (select count(distinct sal) from emp e2 where
e1.sal <= e2.sal);
B) select distinct sal from emp e1 where 3 = (select min(sal) from emp e2 where e1.sal <=
e2.sal);
C) select distinct sal from emp e1 where 3 = (select min(distinct sal) from emp e2 where e1.sal
>= e2.sal);
D) select distinct sal from emp e1 where 3 exists (select count(distinct sal) from emp e2where
e1.sal >= e2.sal);
E) select distinct sal from emp e1 where 3 in (select count(distinct sal) from emp e2where
e1.sal >= e2.sal);
4) Choose the right query to search for strings containing % in a given emp table in
oracle
A) SELECT ename FROM emp WHERE ename LIKE '%?%' ;
B) SELECT ename FROM emp WHERE ename LIKE '%%%' ;
C) SELECT ename FROM emp WHERE ename LIKE '?%' ESCAPE '?';
D) SELECT ename FROM emp WHERE ename LIKE '%?%' ESCAPE '?';
E)SELECT ename FROM emp WHERE ename LIKE '%??' ESCAPE '?';
5) Choose the right query to find those employees who are more than 21 years of age.
A) SELECT NAME FROM emp WHERE hiredate >(SELECT add_months(SYSDATE,(12*21)) FROM dual);
B) SELECT NAME FROM emp WHERE hiredate >(SELECT
months_between(SYSDATE,add_date(21)) FROM dual);

C) SELECT NAME FROM emp WHERE hiredate >(SELECT add_months(SYSDATE,


(12*21)) FROM dual);
D) SELECT NAME FROM emp WHERE hiredate >(SELECT add_months(SYSDATE,-(1221)) FROM dual);
E) SELECT NAME FROM emp WHERE hiredate >(SELECT months_between(SYSDATE,(12*21)) FROM dual);
6) Choose the right query to sort the numbers in our own order ie; sort all the numbers
such that the minimum value should be the last row and the rest numbers should be
sorted in
ascending order

from TabA);

A) select * from TabA order by decode( c1, (select min(c1), to_number(null), c1

B) select * from TabA order by decode( c1, (select least(c1) from TabA), c1);
C) select * from TabA order by decode( c1, (select min(c1) from TabA),
to_number(null));
D) select * from TabA order by decode( c1, (select least(c1) from TabA),
to_number(null), c1);
E) select * from TabA order by decode( c1, (select min(c1) from TabA),
to_number(null), c1);

7) Choose the right query to get the employee details from employee table whose
joining month is January
A)
B)
C)
D)
E)

Select * from emp where to_char(hiredate,'MON') = 'Jan';


Select * from emp where to_char(hiredate,'Mon') = 'Jan';
Select * from emp where to_date(hiredate,'MON') = 'Jan';
Select * from emp where to_char(sysdate,'Mon') = 'Jan';
None

8) Choose the right query to get department,total salary with respect to a department
from employee table order by total salary descending
A) Select DEPARTMENT,count(SALARY) Total_Salary from employee order by
Total_Salary descending
B) Select DEPARTMENT,max(SALARY) Total_Salary from employee group by salary
order by Total_Salary descending
C) Select DEPARTMENT,sum(SALARY) Total_Salary from employee group by
DEPARTMENT
D) Select DEPARTMENT,sum(SALARY) Total_Salary from employee group by
DEPARTMENT order by Total_Salary descending
E) Select DEPARTMENT,SALARY Total_Salary from employee group by DEPARTMENT
9) Choose the right query to Select 20 % of salary from John , 10% of Salary for Roy
and for other 15 % of salary from employee table
A) SELECT FIRST_NAME, CASE FIRST_NAME WHEN 'John' THEN SALARY * .2 WHEN 'Roy'
THEN SALARY * .10 ELSE SALARY * .15 END "Deduced_Amount" FROM EMPLOYEE
B) SELECT FIRST_NAME, CASE FIRST_NAME WHEN 'John' THEN SALARY * .2 WHEN 'Roy'
THEN SALARY * .10 ELSE SALARY * .15 END "Deduced_Amount" FROM EMPLOYEE
C) SELECT FIRST_NAME, CASE WHEN FIRST_NAME WHEN 'John' THEN SALARY * .2
'Roy' THEN SALARY * .10 END SALARY * .15 "Deduced_Amount" FROM EMPLOYEE

D) SELECT FIRST_NAME, CASE FIRST_NAME WHEN 'John' THEN SALARY * .2 WHEN


'Roy' THEN SALARY * .10 ELSE SALARY * .15 "Deduced_Amount" FROM EMPLOYEE
E) none
10)

Observe the output for the following query


select substr('J2eeOnTheNet', -6, 3) from dual.
A)
B)
C)
D)
E)

Net
The
Tech
J2ee
OnThe

11) Choose the correct query to identify the self join in the below mentioned queries
A) select department_name, first_name || ' '|| lastname from departments SELF JOIN
employees.
B) select eid,ename,sal, deptno,deptname from emp, dept where dept.deptno = 10 and
emp.sal > 100000
C) select e1.ename || 'works for' || e2.ename FROM emp e1, emp e2 where e1.mgr =
e2.empno
D) A,B
E) None of the above
12) Choose the correct query to list the employees who are senior to their own
manager
A) select a.* from emp a, emp b where a.mgr > b.empno and a.hiredate < (select
b.hiredate from emp where a.empno > b.empno) order by a.hiredate
B) select a.* from emp a, emp b where a.mgr = b.empno and a.hiredate < orderby
a.hiredate
C) select a.* from emp a, emp b where a.mgr < b.empno and a.hiredate > (select
b.hiredate from emp where a.empno = b.empno) order by a.hiredate
D) select a.* from emp a, emp b where a.mgr = b.empno and a.HIREDATE <
b.HIREDATE
E) select a.* from emp a, emp b where a.mgr = b.empno and a.hiredate = (select
b.hiredate from emp where a.empno < b.empno) order by a.hiredate
13) Choose the correct query to get the 5th highest salary of the employee
A) select a.ename, a.sal from emp a where 5 = (select count(distinct(sal)) from emp b
where a.sal <= b.sal)
B) select a.ename, a.sal from emp a where 5 = (select count(distinct(sal)) from emp b
where a.sal >= b.sal)
C) select a.ename, a.sal from emp a where 5 > (select count(distinct(sal)) from emp b
where a.sal = b.sal)
D) select a.* from emp a, emp b where a.mgr = b.empno and
a.HIREDATE <
b.HIREDATE
E) select a.ename, a.sal from emp a where a.sal > 5

14)

Choose the right one for cursor attributes


A) %OPEN, %COUNT, %FOUND
B) %ISOPEN, %ROW, %FOUND, %NOT FOUND
C) %ISOPEN, %COUNT, %FOUND, %NOT FOUND
D) %ISOPEN, %ROWCOUNT, %FOUND, %NOT FOUND
E) %OPEN, %ROWTYPE, %FOUND, %NOT FOUND

15) Choose the correct query to list the employees who joined before or after 1981
A) select * from emp where hiredate not like '%1981'
B) select * from emp where hiredate not like '81%'
C) select * from emp where hiredate not in 1981
D) select * from emp where hiredate in like 1981
E) None of the above
16) Choose the correct query to list the emps in dept 20 whose sal is greater than the
average sal of dept 10 emps
A) select * from emp where sal >= (select sal) from emp where deptno = 10) and deptno
= 20

B) select * from emp where sal > (select avg(sal) from emp where deptno = 10)
C) select * from emp where sal > (select avg(sal) from emp where deptno = 10) and
deptno = 20
D) select * from emp where sal < (select avg(sal) from emp where deptno = 10) and
deptno = 20
E) None of the above
17)
Choose the option for declaring an existing varray in the table viz; prod_1
in the below mentioned pl/sql block
Note : Table Structure :
Name
Null
Type
---------------------------------------------------P_ID
NUMBER
P_NAME
VARCHAR2(34)
PRODUCTS
PROJ_VARRAY()
A)

create or replace function fun_vrray(p_empno number, p_prod_nme varchar2)


return boolean
is
type p1 is varray (4) of prod_1.products%type;
begin
select products into p1
from prod_emp_1
where p_id = p_empno;
for idx in 1...4
loop
if p1(idx).product_name = p_prod_nme then
return true;
end if;
end loop;
return false;
end;

B)

create or replace function fun_vrray(p_empno number, p_prod_nme varchar2)


return boolean
is
p1 proj_varray;
begin
select products into p1
from prod_emp_1
where p_id = p_empno;
for idx in 1.. p1.count
loop
if p1(idx).product_name = p_prod_nme then
return true;
end if;
end loop;
return false;

C)

end;
create or replace function fun_vrray(p_empno number, p_prod_nme varchar2)
return boolean
is
Type p1 proj_varray;
begin
select products into p1
from prod_emp_1
where p_id = p_empno;
for idx in 1.. p1.count
loop
if p1(idx).product_name = p_prod_nme then
return true;
eif;

end;
create or replace function fun_vrray(p_empno number, p_prod_nme

D)
varchar2)

return boolean
is
type p1 IS VARRAY(5) OF VARCHAR2(10);
begin
select products into p1
from prod_emp_1
where p_id = p_empno;

end;
E)

end loop;

for idx in 1.. p1.count


loop
if p1(idx).product_name = p_prod_nme then
return true;
end if;
end loop;
return false;

None

18) Choose the correct option to display the records between two ranges.

A) select rowid, empno, ename from emp where rowid in (select rowid from emp where
rownum <=10 minus select rowid from emp where rownum<14); ;
B) select rownum, empno, ename from emp where rowid in (select * from emp where
rownum <=10 minus select rowid from emp where rownum<14);
C) select rownum, empno, ename from emp where rowid in (select rownum from emp
where rownum <=10 intersect select rowid from emp where rownum<14);
D) select rownum, empno, ename from emp where rowid in (select rowid from emp where
rownum <=10 union select rowid from emp where rownum<14);
E) select rownum, empno, ename from emp where rowid in (select rowid from emp where
rownum <=10 union all select rowid from emp where rownum<14);
19) Choose the correct option for the use of Translate function in oracle
A)
B)
C)
D)
E)

performs a word wise replacement of a string of numbers


performs a character wise replacement of a number
performs a word wise replacement of a string
performs a character wise replacement of a string
performs both string wise and character wise replacement of a String

20) Choose the correct query to list the year and number of employees did most people
joined the company.
A) select to_char(HIREDATE,'yy') Year count(empno) no of employees from emp
group by to_char(HIREDATE,'yyyy') having count(empno) =(select count(empno) from
emp
B) select to_char(HIREDATE,'yyyy') Year count(empno) no of employees from emp
group by to_char(HIREDATE,'yyyy') having count(empno) =(select max(count(empno)) from emp
where hiredate = to_char(HIREDATE, 'yyyy'))
C) select to_date(HIREDATE,'yyyy') Year count(empno) no of employees from emp
group by to_char(HIREDATE,'yyyy') having count(empno) =(select max(count(empno)) from emp
group by to_char(HIREDATE, 'yyyy'))
D) select to_char(HIREDATE,'yyyy') Year count(empno) no of employees from emp
group by to_char(HIREDATE,'yyyy') having count(empno) =(select max(count(empno)) from emp
group by to_char(HIREDATE, 'yyyy'))
E) select to_char(HIREDATE,'yyyy') Year count(empno) no of employees from emp
group by to_char(HIREDATE,'yyyy') having count(empno) =(select max(count(empno)) from emp
group by to_date(HIREDATE, 'yyyy'))

You might also like