Sql query - orcale database.. Need to retrieve a row with generic condition

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prasanth22
    New Member
    • Oct 2013
    • 1

    Sql query - orcale database.. Need to retrieve a row with generic condition

    Code:
    empid    emplrcd   effdt   effsq
    101          #1    2/1/99    0
    101          #1    3/1/13    1
    101          #1    23/3/13   1 
    101          #1    22/6/13   2
    102          #2    20/6/91   1
    I need to retrieve row 4, and I have written a partial code, please help me with the other half.

    Code:
    select a* from Ps_Job a where a.empid = '101' and a.emprcd ='#1' and a.effdt = (select max(a1.effdt) from Psjob1) where...............
    and a.effseq = (Select  max(a2.effseq) from Ps_job2)
    where..............
    Please help me with the where caluse which should be generic and not row specific. i think it should be filled with nth max concept but not sure.
    Last edited by Rabbit; Oct 10 '13, 05:33 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data.

    Join the table to an aggregate query that returns the max date by empid.

    Comment

    Working...