I have an empolyee payment table by employee number, payment_date, period_end_date and payment. Some time for some employees by each payment_date, there are two or three or four period_end_date. I need write a query to only return last two (period_end_date)s for each payment_date for all employees, no matter how many period_end_date they have on by each payment_date. Can you provide some samples to write this query?
Platform: SQL2k sp3, win 2k sp