Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

I need to see only the latest record in an address book table.

Posted on 2011-09-21
12
Medium Priority
?
819 Views
Last Modified: 2012-05-12
I am working on a query to clean up our JD Edwards address book table. The ALAN8 field is the unique, numeric, Associate address number (primary key). The ALUPMJ field is a 6-digit, numeric, Julian date field.

The F0116 table can have multiple entries for each individual associate (ALAN8) based upon the last date something in the table was updated (ALUPMJ).

I only want to see a single record for each Address Number (ALAN8) based upon on the last updated date (ALUPMJ). I have been scratching my head trying different functions, such as MAX, but I continue to see multiple records listed for each employee number. How should I modify my query in order to see only the last modified record per associate number regardless of the number of modifications in the remaining fields?
_____________________________________________________________________________
      Table F0116
Field      Description      Type      Length
      ALAN8      Address Number      Numeric      8
      ALEFTB      Date - Beginning Effective      Date      6
      ALEFTF      Effective Date Existence (1/0)      Character      1
      ALADD1      Address Line 1      String      40
      ALADD2      Address Line 2      String      40
      ALADD3      Address Line 3      String      40
      ALADD4      Address Line 4      String      40
      ALADDZ      Postal Code      String      12
      ALCTY1      City            String      25
      ALCOUN      County            String      25
      ALADDS      State            String      3
      ALCTR      Country            String      3
_____________________________________________________________________________      

SQL View of Query:
SELECT PRODDTA_F0116.ALAN8, Max(PRODDTA_F0116.ALUPMJ) AS MaxOfALUPMJ, PRODDTA_F0116.ALADD1, PRODDTA_F0116.ALADD2, PRODDTA_F0116.ALADD3, PRODDTA_F0116.ALADD4, PRODDTA_F0116.ALCTY1, PRODDTA_F0116.ALCOUN, PRODDTA_F0116.ALADDS, PRODDTA_F0116.ALADDZ, PRODDTA_F0116.ALCTR
FROM PRODDTA_F0116
GROUP BY PRODDTA_F0116.ALAN8, PRODDTA_F0116.ALADD1, PRODDTA_F0116.ALADD2, PRODDTA_F0116.ALADD3, PRODDTA_F0116.ALADD4, PRODDTA_F0116.ALCTY1, PRODDTA_F0116.ALCOUN, PRODDTA_F0116.ALADDS, PRODDTA_F0116.ALADDZ, PRODDTA_F0116.ALCTR
ORDER BY Max(PRODDTA_F0116.ALUPMJ) DESC;
_____________________________________________________________________________      

I have included a screen shot ss an example using a single ALAN8 that has three (3) records. I only want to see the latest Julian date, 107109.  

Thanks in advance for your assistance.

TW

 Screen Shot Of Executed Query for a Single ALAN8
0
Comment
Question by:Tom Winslow
  • 4
  • 4
  • 2
  • +1
12 Comments
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 36574316
Can you post the database, or a cut-down version of it?  Most likely the problem is that (apart from the Date field) there is unique data in some records, thus preventing you from seeing just the record with the most recent date.
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 36574323
You might need to create a separate query to get the unique ID of the record with the most recent date, and then use the ID to filter the form or subform for just that record.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36574418
try this query

select * from F0116
where ALUPMJ in (select max([ALUPMJ]) from F0116 as F where F.ALAN8=F0116.ALAN8)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:Norie
ID: 36574435
Try this:

SELECT *
FROM F0116 AS A

WHERE ALUPMJ = (SELECT MAX (ALUPMJ) FROM F0116 WHERE A.ALAN8 = ALAN8 GROUP BY ALAN8)
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36574475
this shuld run faster


SELECT  T.*
FROM
    PRODDTA_F0116  AS T
 INNER JOIN
       (SELECT
             Max(T2.[ALUPMJ]) as MaxALUPMJ, [ALAN8]
         FROM
             PRODDTA_F0116  T2  
             Group By T2.ALAN8
        ) T1
ON  T.[ALUPMJ]=T1.MaxALUPMJ and T.ALAN8=T1.ALAN8


0
 

Author Comment

by:Tom Winslow
ID: 36575697
I have been requested to upload a portion of the table. Please see attached.
tblF0116Project.csv
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36575757
Tom,

you uploaded an incomplete file..

where is column for ALUPMJ ?

have you tried the query i posted at http:#a36574475 ?
0
 
LVL 35

Expert Comment

by:Norie
ID: 36575798
There is no date field at all and no field called ALUPMJ.
0
 

Author Comment

by:Tom Winslow
ID: 36575863
OOPS! Uploading another file.
tblF0116Project.csv
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 36575917
test this, run query1



DB-Q-27319964.mdb
0
 

Author Comment

by:Tom Winslow
ID: 36582511
I am experimenting with the answers and will get back as soon as possible.
0
 

Author Closing Comment

by:Tom Winslow
ID: 36817440
Thanks. I learned a lot from studying this query.

tw
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question