Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Most recent record Post Reply Post New Topic
Author Message
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Topic: Most recent record
     Posted: 10 Jun 2011 at 10:44am
Hi,
 
is it possible to get the most recent record from a  connected table?
example
 
I have a client with admit info, but on another table client can have many refferals. I want to pickup the most recent if (say) field1='test'.
 
Thanks
Joe
 
 
I've been looking around and I 'Think" I canb create a sql expression field?
I create
 
(Select max("USER_DEFINED_DATA"."EffDate")from user_defined_data where "USER_DEFINED_DATA"."CAD21" = 'CSA: Assigned' )
 
but what do I do with it now?
lol
 
 
What about 'Command' not sure how to use /
Would it be a better way?
 
 


Edited by jbalbo - 10 Jun 2011 at 11:17am
IP IP Logged
freestylepunk
Newbie
Newbie
Avatar

Joined: 05 May 2011
Location: United States
Online Status: Offline
Posts: 13
Quote freestylepunk Replybullet Posted: 14 Jun 2011 at 2:40pm
One way I can think of (but certainly not the most efficient way) is to group by whatever your unique key is, sort by effdate ascending, then put the effdate field into the group footer.
 
Another way you can try is to play around with the "maximum" value in the running totals.  Not sure if it will work on direct comparisons with date and time values but no harm trying.  ^.^
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 15 Jun 2011 at 4:03am
you could try a Command.  It is usually a simple SQL Select.
select max(field) as maxDate, id from table where field1 = 'test' group by id
 
you would create this where you usually select tables / stored procedures from, just click add command.
 
you would then link this table to your other tables using the Id. you can then access the max field as you would any other.
 
HTH
IP IP Logged
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