Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Select most recent version of each record Post Reply Post New Topic
Author Message
calvin-c
Newbie
Newbie
Avatar

Joined: 18 Dec 2006
Location: United States
Online Status: Offline
Posts: 6
Quote calvin-c Replybullet Topic: Select most recent version of each record
    Posted: 19 Nov 2007 at 12:29pm
I have a table in which multiple versions of some records are stored. I'm designing a report that will list the most recent version of each record. The SQL I'm trying to duplicate is:
Select * from TableA A where sequence=(select max(sequence) from TableA B where A.partialkey = B.partialkey)

The SQL works, but I can't seem to translate it into Crystal formulas. It looks like a subreport should work (linking with partialkey, returning max(sequence) in a shared variable, and suppressing details when sequence < the variable) but it's inconsistent and I can't figure out why.

Does anyone have any suggestions? Thx.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 19 Nov 2007 at 12:55pm
yes, I use the SQL as well. I saw that Hilfy posted a way to do this via CR that is probably what you are looking for. Browse (search) her posts within the past couple weeks and you should find it.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
calvin-c
Newbie
Newbie
Avatar

Joined: 18 Dec 2006
Location: United States
Online Status: Offline
Posts: 6
Quote calvin-c Replybullet Posted: 19 Nov 2007 at 2:30pm
Afraid I couldn't find the post you were referring to, but I've noticed something that might help. I added grouping by partialkey & displayed all the sequence numbers (subreport formula value, main report formula value, and record value) and noticed that it wasn't reporting a main report formula value for the 1st record & that all subsequent records reported the previous value-and it didn't report all the records but I need to modify my test data to check why. I think it isn't resetting the main report formula value & therefore ended at the partialkey record with the highest sequence-which happened to also be the highest partialkey that got reported.

If that's the case I've got two issues: evaluation time & resetting.
IP IP Logged
wattsjr
Groupie
Groupie
Avatar

Joined: 25 Jun 2007
Location: United States
Online Status: Offline
Posts: 51
Quote wattsjr Replybullet Posted: 19 Nov 2007 at 3:12pm
Hi calvin-c,
 
I think that the post that Brian was referring to was:
 
 
Regards,
-jrw
IP IP Logged
calvin-c
Newbie
Newbie
Avatar

Joined: 18 Dec 2006
Location: United States
Online Status: Offline
Posts: 6
Quote calvin-c Replybullet Posted: 19 Nov 2007 at 3:21pm
Yes, that looks like an appropriate post-don't know why I didn't see it, but I arrived at the same conclusion while testing the anomalies in the evalution timing. Put the subreport in the group header & all the inconsistencies went away. Marvelous. Thanks, all.
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.000 seconds.