I'm trying to write a sql statement to relieve countless hours of manual effort. Please help if you can.
Keeping the data simple, think of one user listed 3 times. Action dates are, 8/30/2009, 9/5/2009, and 9/5/2009, using identical account codes. Sequence value for 8/30 is 0. Sequence values for 9/5 are 0 and 1. How can I only show the value for 8/30 with a sequence of 0 (highest for group in that date and account code range) and the one value from 9/5 with a sequence of 1 (max for the date and for the specific account code on that date)? Normally there are many names, account codes, and dates.
I have this:
SELECT NAME, ANNUAL_RT, Acct_CD, DIST_PCT, FUNDING_BEG_DT, JOB_EFFSEQ, ACTION_DT
FROM Table
GROUP BY NAME, ANNUAL_RT, Acct_CD, DIST_PCT, FUNDING_BEG_DT, JOB_EFFSEQ, ACTION_DT
ORDER BY Acct_CD, Max(ACTION_DT);