Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 the sign only if the value is... useit DFSORT/ICETOOL 3 Wed Oct 04, 2017 5:53 pm
No new posts Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm
No new posts Display upon console bipinpeter COBOL Programming 1 Thu Jun 22, 2017 12:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us