Link to home
Start Free TrialLog in
Avatar of restockett
restockett

asked on

How do I query for the most recent modified record?

Can someone help me to pull just the most recent modified record for a voter id.  I thought using max would do it but I am obviously wrong.  My query is below.

SELECT   JURISDICTIONS.NAME,
      VOTER_AUDITS.ID,
      VOTER_AUDITS.VTR_ID,
      MAX(VOTER_AUDITS.MODIFIED_DATE),
      VOTER_AUDITS.OLD_VALUE,
      VOTER_AUDITS.NEW_VALUE,
      VOTER_AUDITS.AUDTYP_ID
 FROM      JURISDICTIONS,VOTER_AUDITS, VOTERS
WHERE    JURISDICTIONS.CODE = VOTER_AUDITS.JS_CODE
  AND       VOTER_AUDITS.js_code ='46'
  AND       VOTER_AUDITS.AUDTYP_ID='7'
  AND       VOTER_AUDITS.VTR_ID = VOTERS.ID
GROUP BY JURISDICTIONS.NAME,
      VOTER_AUDITS.ID,
      VOTER_AUDITS.VTR_ID,
      VOTER_AUDITS.OLD_VALUE,
      VOTER_AUDITS.NEW_VALUE,
      VOTER_AUDITS.AUDTYP_I
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of restockett
restockett

ASKER

Thanks, that works.  I have more questions about how to use this as a subquery for another query but i will enter as a new Question