Tuesday, February 24, 2009

Quaries 1

51) Display the name of employees who earn Highest Salary?
Ans: select ename, sal from tvsemp where sal>=(select max(sal) from tvsemp );
52) Display the employee Number and name for employee working as clerk and earning highest salary among the clerks?
Ans: select ename,empno from tvsemp where sal=(select max(sal) from tvsemp where job='CLERK') and job='CLERK' ;
53) Display the names of salesman who earns a salary more than the Highest Salary of the clerk?
Ans: select ename,sal from tvsemp where sal>(select max(sal) from tvsemp where job='CLERK') AND job='SALESMAN';
54) Display the names of clerks who earn a salary more than the lowest Salary of any salesman?
Ans: select ename,sal from tvsemp where sal>(select min(sal) from tvsemp where job='SALESMAN') and job='CLERK';
55) Display the names of employees who earn a salary more than that of jones or that of salary greater than that of scott?
Ans: select ename,sal from tvsemp where sal>all(select sal from tvsemp where ename='JONES' OR ename='SCOTT');
56) Display the names of employees who earn Highest salary in their respective departments?
Ans: select ename,sal,deptno from tvsemp where sal in (select max(sal) from tvsemp group by deptno);
57) Display the names of employees who earn Highest salaries in their respective job Groups?
Ans: select ename,job from tvsemp where sal in (select max(sal) from tvsemp group by job);
58) Display employee names who are working in Accounting department?
Ans: select e.ename,d.dname from emp e,dept d where e.deptno=d.deptno and d.dname='ACCOUNTING';
59) Display the employee names who are Working in Chicago?
Ans: select e.ename,d.loc from emp e,tvsdept d where e.deptno=d.deptno and d.loc='CHICAGO';
60) Display the job groups having Total Salary greater than the maximum salary for Managers?
Ans: select job ,sum(sal) from tvsemp group by job having sum(sal) >(select max(sal) from tvsemp where job='MANAGER');

No comments:

Post a Comment