Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Display those employees that have salary > average salary

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Display those employees that have salary > average salary
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    Post subject:
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    Post subject: Reply to: Display those employees that have salary > aver
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Display ZEDLMSG without Pressing F1 &... anandgbe CLIST & REXX 8 Thu Dec 15, 2016 4:20 pm
No new posts How to display value of an exit param... lind sh CICS 2 Sun Oct 09, 2016 12:28 pm
This topic is locked: you cannot edit posts or make replies. DSList (3.4) cannot display Chinese c... jacobdng TSO/ISPF 4 Wed Oct 05, 2016 2:51 pm
This topic is locked: you cannot edit posts or make replies. Get and display content of an address... lind sh CICS 1 Mon Aug 08, 2016 9:18 am
No new posts How to display data in separate lines... salilnigam1970 DFSORT/ICETOOL 2 Tue Jan 26, 2016 9:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us