consider a table which contain 4 columns,ename,eno,sal and
deptno, from this table i want to know ename who having
maximum salary in deptno 10 and 20.

Answers were Sorted based on User's Feedback



consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / purushotham

select ename from table where sal in
(select max(sal) from table_name
where deptno in ('10','20')
group by deptno);

Is This Answer Correct ?    16 Yes 8 No

consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / srilekha

select ename from table where sal=(select max(sal) from
table) and depetno in (10,20)

Is This Answer Correct ?    27 Yes 20 No

consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / rohan

select empno from emp where (sal,deptno) in ( select max
(sal),deptno from emp where deptno in (10,20) group by
deptno)

Is This Answer Correct ?    13 Yes 6 No

consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / rashmi_raju

SELECT ename FROM emp WHERE sal =(SELECT MAX(sal) FROM emp
WHERE deptno=10)
UNION
(SELECT ename FROM emp WHERE sal =(SELECT MAX(sal) FROM emp
WHERE deptno=20))

Is This Answer Correct ?    6 Yes 0 No

consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / guest

Select emp_name from emp where sal =(Select Max(sal) from
emp where deptno=10) and deptno=10 union
Select emp_name from emp where sal =(Select Max(sal) from
emp where deptno=20)and deptno=20

Is This Answer Correct ?    6 Yes 1 No

consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / kishore

select * from em where sal in (select max(sal) from em
where dno in (10,20) group by dno) and dno in (10,20)

where em = table name
dno = department number
sal = salary

Is This Answer Correct ?    4 Yes 3 No

consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / anil pednekar

select table1.ename from (select deptno, max(sal) as sal1
from table1 group by deptno having deptno in(1,2)) as T1,
table1 where T1.deptno=table1.deptno and
T1.sal1=table1.sal

Is This Answer Correct ?    1 Yes 0 No

consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / ashim

select * from (select id,dept,sal,dense_rank() over
(partition by dept order by sal desc) p from a_tab1)
where p=1

....by using this program we can find out the nth salary of
different department jus give p=n

Is This Answer Correct ?    1 Yes 0 No

consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / abhishekjaiswal

select last_name,salary from employees where (salary,department_id) in ( select max(salary),
department_id from employees where department_id in (10,20) group by 
department_id) 
/
Output
LAST_NAME                     SALARY
------------------------- ----------
Hartstein                      13000
Whalen                          4400

Is This Answer Correct ?    1 Yes 0 No

consider a table which contain 4 columns,ename,eno,sal and deptno, from this table i want to know ..

Answer / vishnu prasad.ma

SELECT A.EMP_NAME, SUM(B.MAX_SALARY) AS MAX_SAL, B.EMP_DEPT_NO FROM EMP_DETAILS A,
(SELECT MAX(EMP_SAL) AS MAX_SALARY, EMP_DEPT_NO FROM EMP_DETAILS WHERE EMP_DEPT_NO IN (10,20)
GROUP BY EMP_DEPT_NO) B
WHERE
A.EMP_SAL = B.MAX_SALARY
AND A.EMP_DEPT_NO = B.EMP_DEPT_NO
GROUP BY A.EMP_NAME, B.EMP_DEPT_NO

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What is user define exception and example

1 Answers   HP, KP,


What is ROWID?

8 Answers  


Can we create index on primary key?

0 Answers  


What are views in sql?

0 Answers  


table having two columns - entity,zone enity zone pen east pen west pen north pen south pen east pencil east pencil east pencil west I want the output as : entity east west north south pen 2 1 1 1 pencil 2 1 0 0

2 Answers  






I have one table and column is c1 pk, c2 not null,c3 not null and 200 row in it and i add c4 column and value, how can is possible

9 Answers  


What is the difference between explicit and implicit cursors in oracle?

0 Answers  


where are cookies actually stored on the hard disk? : Sql dba

0 Answers  


How would you go about increasing the buffer cache hit ratio? 0. Explain the difference between a hot backup and a cold backup and the benefits associated with each 1. You have just had to restore from backup and do not have any control files. How would you go about bringing up this database? 2. How do you switch from an init.ora file to a spfile? 3. Explain the difference between a data block, an extent and a segment. 4. Give two examples of how you might determine the structure of the table DEPT. 5. Where would you look for errors from the database engine? 6. Compare and contrast TRUNCATE and DELETE for a table. 7. Give the reasoning behind using an index. 8. Give the two types of tables involved in producing a star schema and the type of data they hold. 9. What type of index should you use on a fact table? 10. Give two examples of referential integrity constraints. 11. A table is classified as a parent table and you want to drop and re-create it. How would you do this without affecting the children tables? 12. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and disadvantages to each. 13. What command would you use to create a backup control file? 14. Give the stages of instance startup to a usable state where normal users may access it. 15. What column differentiates the V$ views to the GV$ views and how? 16. How would you go about generating an EXPLAIN plan?

2 Answers  


What is a constraint. Types of constraints ?

5 Answers   Accenture, BirlaSoft,


what is a table called, if it has neither cluster nor non-cluster index? What is it used for? : Sql dba

0 Answers  


What are some emotional triggers?

0 Answers  


Categories