Help Needed For writting a query (SQl Server 2005).

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dinesh

    Help Needed For writting a query (SQl Server 2005).

    Hi experts,

    I am working on SQL Server 2005.
    Now i have to write a query which will extract some data from 3 to 4
    tables.
    My main table is having few columns supose 4 columns.

    EmpNo EmpName Date_Of_Joining Date_Of_Apprais al

    Now records are entering in this table. But here If any emp gets any
    appraisal the a new row is entered and first 3 coluns will be same.

    for ex

    EmpNo EmpName Date_Of_Joining
    Date_Of_Apprais al
    1 John 21/01/2000 24/01/2001
    1 John 21/01/2000 20/01/2002
    1 John 21/01/2000 2/01/2007
    1 John 21/01/2000 1/01/2008


    Now i have to write a query which will have all these columns
    and if there is any employee who is having more than one row in the
    table then one extra column will be added in the result and It will
    show you the 5 columns
    And only last two rows will be taken and result will be like this

    EmpNo EmpName Date_Of_Joining
    Last_Date_Of_Ap praisal Previous_Date_O f_Appraisal
    1 John 21/01/2000 1/01/2008 2/01/2007


    How i can get this result, Please help me.



    Any help wil be appriciated.

    Regards
    Dinesh
Working...