1 Reply Latest reply on Jul 24, 2014 12:29 PM by thatJeffSmith-Oracle

    Complex  SQL scenario

    KVB

      I have a table with multiple employees,the records needs to be picked up is on different conditions.
      I have done them one by one and did UNION.But I am looking for any other manner. Please throw any light on this to achieve in a better manner.

      ID TYPE_CD EFFDT  SEQ
      1 A 1-Jul-14 1
      1 O 1-Jul-14 2
      1 N 1-Jul-14 3
      If there are codes in A,O,N then N needs to be picked up
        
      2 A 5-Jul-14 4
      2 A 5-Jul-14 5
      2 O 5-Jul-14 6
      2 N 5-Jul-14 7
      If there are multiple A's followed by O and N,then maximum sequence number needs to be picked up.  
      3 A 5-Jul-14 8
      3 A 5-Jul-14 9
      3 A 5-Jul-14 10
      3 A 5-Jul-14 11
      If there are multiple A's,then maximum seqid needs to be picked up.
        
      4 A 5-Jul-14 12
      4 D 5-Jul-14 13

      If there are A and D,then this should be neglected.