Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Returning the most recent dates from table Post Reply Post New Topic
Author Message
Alex
Newbie
Newbie


Joined: 28 Jan 2008
Location: Canada
Online Status: Offline
Posts: 22
Quote Alex Replybullet Topic: Returning the most recent dates from table
    Posted: 07 Feb 2008 at 6:23am
Hello, I am looking a formula that will filter out records with most recent date from a table. thanks.
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 07 Feb 2008 at 7:08am
The simplest method is to use the TOP keyword.  So, suppose you want the most recent hundred entries.  Have your SQL look like:

SELECT TOP 100 *
FROM MyTable
ORDER BY MyDate DESC

This can also be done in Crystal, using the Group Sort Expert.  Unfortunately, it's a bit less straightforward, as you can't simply do a Top N on all the records.  Instead, create a Group based on the unique ID of your records (hence, generating one "group" for each record).  In the Group Footer, put a summary field for the Maximum of the date field in question.  Then, use the Group Sort Expert to do your Top N.


IP IP Logged
Alex
Newbie
Newbie


Joined: 28 Jan 2008
Location: Canada
Online Status: Offline
Posts: 22
Quote Alex Replybullet Posted: 07 Feb 2008 at 7:20am
Thanks a lot Lugh.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.