Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Posts
    1

    Post Unanswered: Differential Calculation!

    Hello Everyone,
    Can Someone pls. give me a hint on how to find the different between two turple in database SQL for example:

    Find the difference in salary between the supervisor and employee.

    I will prefer not to spoon fed. I just need the formula. Thanks.

  2. #2
    Join Date
    Nov 2002
    Posts
    833
    select col1, ..., col<n> from table1
    minus
    select col1, ..., col<n> from table2;

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    No, that's not what is wanted. The requirement is to "find the difference in salary between the supervisor and employee".

    There is more than one way to do this. Here is one:
    Code:
    SQL> select e.ename, m.ename mname, e.sal esal, m.sal msal, m.sal-e.sal diff
      2  from emp m, emp e
      3  where e.mgr = m.empno;
    
    ENAME      MNAME            ESAL       MSAL       DIFF
    ---------- ---------- ---------- ---------- ----------
    JONES      KING             2975       5000       2025
    CLARK      KING             2450       5000       2550
    BLAKE      KING             2850       5000       2150
    JAMES      BLAKE             950       2850       1900
    TURNER     BLAKE            1500       2850       1350
    MARTIN     BLAKE            1250       2850       1600
    WARD       BLAKE            1250       2850       1600
    ALLEN      BLAKE            1600       2850       1250
    MILLER     CLARK            1300       2450       1150
    FORD       JONES            3000       2975        -25
    SCOTT      JONES            3000       2975        -25
    ADAMS      SCOTT            1100       3000       1900
    SMITH      FORD              800       3000       2200

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •