Home » Other » General » How many employees have job of manager,salesman and clerk . Give the answer in three different colum
How many employees have job of manager,salesman and clerk . Give the answer in three different colum [message #103745] Wed, 03 March 2004 03:20 Go to next message
Zeeshan Nisar
Messages: 1
Registered: March 2004
Junior Member
plz anwser my this question......

How many employees have job of manager,salesman and clerk .. Give the answer in three different columns ???
Re: How many employees have job of manager,salesman and clerk . Give the answer in three different c [message #103748 is a reply to message #103745] Thu, 04 March 2004 08:12 Go to previous message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
SQL> SELECT *
  2  FROM   emp
  3  /
  
     EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM     DEPTNO
---------- ---------- --------- ---------- ---------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 12/17/1980        800                    20
      7499 ALLEN      SALESMAN        7698 2/20/1981        1600        300         30
      7521 WARD       SALESMAN        7698 2/22/1981        1250        500         30
      7566 JONES      MANAGER         7839 4/2/1981         2975                    20
      7654 MARTIN     SALESMAN        7698 9/28/1981        1250       1400         30
      7698 BLAKE      MANAGER         7839 5/1/1981         2850                    30
      7782 CLARK      MANAGER         7839 6/9/1981         2450                    10
      7788 SCOTT      ANALYST         7566 12/9/1982        3000                    20
      7839 KING       PRESIDENT            11/17/1981       5000                    10
      7844 TURNER     SALESMAN        7698 9/8/1981         1500          0         30
      7876 ADAMS      CLERK           7788 1/12/1983        1100                    20
      7900 JAMES      CLERK           7698 12/3/1981         950                    30
      7902 FORD       ANALYST         7566 12/3/1981        3000                    20
      7934 MILLER     CLERK           7782 1/23/1982        1300                    10
  
14 rows selected.
  
SQL> <font color=blue>SELECT SUM(DECODE(e.job,'SALESMAN',1,0))    salesmen</font>
  2  <font color=blue>,      SUM(DECODE(e.job,'MANAGER',1,0))     managers</font>
  3  <font color=blue>,      SUM(DECODE(e.job,'CLERK',1,0))       clerks</font>
  4  <font color=blue>FROM   emp        e</font>
  5  /
  
  SALESMEN   MANAGERS     CLERKS
---------- ---------- ----------
         4          3          4
  
SQL>
Happy homeworking,

Art.
Previous Topic: Difference between oracle8 and Oracle8i and oracle9i
Next Topic: How to apply outer join condition for 'IN' operator
Goto Forum:
  


Current Time: Tue Nov 26 22:47:23 CST 2024