IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Display those employees that have salary > average salary


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
murali_andaluri
Currently Banned

New User


Joined: 07 May 2005
Posts: 22

PostPosted: Wed Oct 17, 2007 11:47 am
Reply with quote

1. An EMPLOYEE table has following fields: EMP_ID, SALARY.
a) Write a query to display those employees that have salary > average salary of all employees.
b) Write a query to display count of those employees that have salary > average salary of all employees.


2.EMPNO ENAME JOB MGR HIREDATE SAL DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 30

DEPTNO DNAME LOC
10 STORE CHICAGO
20 RESEARCH DALLAS
30 SALES NEW YORK
40 MARKETING BOSTON

a). List all employees who are working in a department located in BOSTON:
b). List all those employees who are working in the same department as their manager
c). Retrieve the minimum and maximum salary of clerks for each department having
more than three clerks.
Back to top
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Wed Oct 17, 2007 11:54 am
Reply with quote

1 A) SELECT EMPID FROM TABLENAME WHERE SALARY > (SELECT AVG(SALARY) FROM TABLENAME);
1 B) SELECT COUNT(*) FROM TABLENAME WHERE SALARY > (SELECT AVG(SALARY) FROM TABLENAME);

and for second one are u using one table or two tables.
Back to top
View user's profile Send private message
murali_andaluri
Currently Banned

New User


Joined: 07 May 2005
Posts: 22

PostPosted: Wed Oct 17, 2007 12:14 pm
Reply with quote

Thanks nuthan...

second one is using two tables
Back to top
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Wed Oct 17, 2007 12:54 pm
Reply with quote

Try and let me know.

2 A) SELECT EMPNO, ENAME FROM EMPTABLE A, DEPTABLE B WHERE A.DEPNO = B.DEPTNO AND B.LOC = 'BOSTON';

2 B) SELECT A.EMPNO, A.ENAME FROM EMPTABLE A, EMPTABLE B WHERE A.MGR = B.EMPNO AND A.DEPTNO = B.DEPTNO;

2 C) SELECT deptno, MIN(SALARY), MAX(SALARY) FROM TMPTABLE GROUP BY DEPTNO HAVING COUNT(*) > 3;
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Timestamp difference and its average ... DB2 11
No new posts How to display the leading zeros of a... DB2 7
No new posts SDSF display Max-RC in different colors TSO/ISPF 4
No new posts Converting a file from PD to display ... SYNCSORT 4
No new posts Unable to display comp variable COBOL Programming 4
Search our Forums:

Back to Top