7
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 '?';

Question Paper

Embed Size (px)

DESCRIPTION

ouestions

Citation preview

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 add_months(SYSDATE,-(12-21)) 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 inascending order

A) select * from TabA order by decode( c1, (select min(c1), to_number(null), c1 from TabA); 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) Select * from emp where to_char(hiredate,'MON') = 'Jan'; B) Select * from emp where to_char(hiredate,'Mon') = 'Jan'; C) Select * from emp where to_date(hiredate,'MON') = 'Jan'; D) Select * from emp where to_char(sysdate,'Mon') = 'Jan'; E) 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) Net B) The C) Tech D) J2ee E) 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)

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.HIREDATEE) 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 1981D) select * from emp where hiredate in like 1981E) 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 = 20B) 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 = 20D) select * from emp where sal < (select avg(sal) from emp where deptno = 10) and deptno = 20E) 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_1where 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_1where 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; end; C) 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_1where p_id = p_empno; for idx in 1.. p1.count loop if p1(idx).product_name = p_prod_nme then return true; eif; end loop; end; D) create or replace function fun_vrray(p_empno number, p_prod_nme varchar2)return boolean is type p1 IS VARRAY(5) OF VARCHAR2(10); begin select products into p1 from prod_emp_1where 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; end; E) 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