Selecting the Most recent last performed date for each record

I had this question after viewing Maximum date for Crystal Reports.

I need to be able to select only the most recent complete date for each record.  I have tried everything I can think of and have failed miserably so far.  This can't be this hard.  I have tried everything I could find on the site.  Any help would be great.

Thanks
Rich

PM_ID_NUMBER      PM_GEN_WO_NUMBER      PM_DUE_DATE      PM_COMPLETE_DATE
00006514      00224806      20161231      20151201
00006514      00209934      20161231      20141208
00006514      00195108      20161231      20131216
00006514      00181568      20161231      20130204
00006514      00177627      20161231      20121115
00006515      00223658      20161130      20151027
00006515      00188866      20170731      20130701
00006515      00190107      20170831      20130819
00006515      00183780      20170331      20130321
00006515      00185105      20170430      20130401
00006515      00186295      20170531      20130506
00006576      00231802      20160930      20160516
00006576      00228092      20160930      20160301
00006576      00224832      20160930      20160104
00006576      00221174      20160930      20150910
00006576      00217433      20160930      20150608
00006576      00213522      20160930      20150311
00006576      00210092      20160930      20141215
00006577      00223670      20161130      20151102
00006577      00223671      20161130      20151102
00006577      00216222      20161130      20150604
00006577      00216223      20161130      20150506
00006577      00208837      20161130      20141110
RDMcLaurineAsked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
You can also use a COMMAND for the data source.  The SQL for it will be something like this

SELECT T1.PM_ID_NUMBER, T1.PM_GEN_WO_NUMBER, T1.PM_DUE_DATE, T1.PM_COMPLETE_DATE
 FROM   YourTable T1
WHERE T1.PM_COMPLETE_DATE =  (SELECT MAX(T2.PM_COMPLETE_DATE) FROM  YourTable T2 WHERE T2.PM_ID_NUMBER = T1.PM_ID_NUMBER )

Open in new window


mlmcc
MaxDate-using-a-Command.rpt
0
 
mlmccConnect With a Mentor Commented:
If you are simply trying to display the dat you can do this with groups.

Add a group on PM_ID_NUMBER
Add a sort on PM_COMPLETE_DATE
   Make the sort descending
Put the fields in the group header rather than the detail section
Suppress the details and group footer


This works if you only are displaying the data as the report shows.
If you are doing any summaries or other calculations on the data then this idea fails because all the data is still in the report.


I attached a sample report

mlmcc
MaxDateData.xls
MaxDate-by-Grouping.rpt
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.