1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

SQL query

Discussion in 'SQL PL/SQL' started by krithika@2001, Jul 14, 2009.

  1. krithika@2001

    krithika@2001 Active Member

    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    80
    Hi

    I have a table for example like

    ID Name Salary diffsal

    1 kitty 50

    2 karthi 40

    In diffsal I should calculate the diff in salary between the first two coumns.How to write a query for this?

    Thanks and Regards
    Krithika
     
  2. Kirti

    Kirti Forum Advisor

    Messages:
    46
    Likes Received:
    12
    Trophy Points:
    130
    You mean the diff in salary of the first two rows? well in that case you can either use self-join in case you are subtracting based on some id. Else you will have to use analytic function.
     
  3. krithika@2001

    krithika@2001 Active Member

    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    80
    Can you show me the query?I dont know how to write self joins
     
  4. Sadik

    Sadik Community Moderator Forum Guru

    Messages:
    1,906
    Likes Received:
    252
    Trophy Points:
    1,455
  5. krithika@2001

    krithika@2001 Active Member

    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    80
    Thanks Sadik.This material was gud.Rajavu can you tell me the solution for this query.Plzzzzzz