Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: This sql problem is driving me crazy. Post Reply Post New Topic
Author Message
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Topic: This sql problem is driving me crazy.
     Posted: 10 May 2010 at 4:34am
 I have a bit of SQL which brings back data and among it I have the subquery
(select max(start_date) from gov_link where person_id = ip.applic_id) as gov_start,
When I run this as sql, it brings back the latest start date, no problems.
(It has date parameters to limit the main records, not on the same dates as the subquery.)
 
Then I put it in Crystal, as a Command, just as it is, with the 2 parameters. Run for the same dates, and now it has brought back not the latest start date but the one before, on some of the records but not all.
 
It has to be something to do with the dates and the way they are held in Crystal and Oracle.  Nothing else differs.Ermm
Any ideas?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 May 2010 at 3:31am
does the command have parameters or is it basically a straight select statement?
 
You might want to use a command to bring back the person_id and max(start_date) as StartDate  and then link the command output to some other table.  I haven't used command too often, but it could be that the parameters in the command are getting it confused.
 
HTH
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 11 May 2010 at 9:49pm
Yes, the command has two date parameters, to indicate a range. The subquery is independent of that, it should run for each record and has no relation to the overall dates.
And I have also written it with hard-coded dates, and the same thing happens.
I use Commands a lot. I could use SQL statements within a report using tables, but I want to use a command for a dynamic parameter (for something else) eventually, and that means SQL statements  can't be used here.
I have ended up by grouping on the gov_link date, and putting it in the footer of that group so only the latest one shows.
But this is so inelegant.Smile
And I would like to figure out why the sql is different for another time, which is bound to occur.
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