Solved

Selecting the Most recent last performed date for each record

Posted on 2016-09-29
3
16 Views
Last Modified: 2016-10-18
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
0
Comment
Question by:RDMcLaurine
  • 2
3 Comments
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 500 total points (awarded by participants)
ID: 41822109
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
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points (awarded by participants)
ID: 41822154
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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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