0

I need to delete all the rows with a max value of duty_per_id where the rotn_prng_nbr and empl_nbr are the same (not the same to each other, but the max where of all of the rows where those two remain constant). From the table below it should delete rows 3,7 and 9.

rotn_prng_nbr empl_nbr duty_perd_id
B93 12 1
B93 12 2
B93 12 3
B21 12 1
B21 12 2
B21 12 3
B21 12 4
B21 18 1
B21 18 2

using SAS EG.

1 Answers1

0

One method uses a correlated subquery:

select t.*
from t
where t.duty_perd_id < (select max(t2.duty_perd_id)
                        from t t2
                        where t2.rotn_prng_nbr = t.rotn_prng_nbr and
                              t2.empl_nbr = t.empl_nbr
                       );
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786