Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Using multiple OR's in Select Expert Post Reply Post New Topic
Author Message
degraves
Newbie
Newbie


Joined: 03 Feb 2010
Online Status: Offline
Posts: 2
Quote degraves Replybullet Topic: Using multiple OR's in Select Expert
     Posted: 03 Feb 2010 at 6:53am

I am creating a reconciliation report to compare data in two databases (different departments).   I need to know which records exist in one database and not the other [DONE], I also need to know if there is a discrepency in the data between records that match.  Here is where I am having trouble.  Rather than create a report to compare each field for accuracy, I am trying to make one report that uses OR's to look for and display problems:

{%CON_BANNER_HOLD} = "1" and
{RPT_CONTRAVENTION_VIEW.CON_AMOUNT_DUE} > 5.00 and
Not(IsNull({RPT_ENTITY_VIEW.ENT_PRIMARY_ID})) and
Not (IsNull({BannerHolds.PUID}))
 
This is the standard filtering block. after this I have several fields that I am comparing and I want to make it look something like this:
 
{%CON_BANNER_HOLD} = "1" and
{RPT_CONTRAVENTION_VIEW.CON_AMOUNT_DUE} > 5.00 and
Not(IsNull({RPT_ENTITY_VIEW.ENT_PRIMARY_ID})) and
Not (IsNull({BannerHolds.PUID})) and
AAA.ZZZ <> BBB.ZZZ or
AAA.YYY <> BBB.YYY or
AAA.XXX <> BBB.XXX
 
The problem is, I believe the code is happening sequencially..that is to say the OR's are not including the first block of AND's and is giving me the AND block, OR the ZZZ, OR the YYY, OR the XXX. 
 
I realize that I could just repeat the AND block with each OR, but the report seems to run doggedly slow when I do this.  I know in SQL you can group several criteria staments like this:
 
{%CON_BANNER_HOLD} = "1" and
{RPT_CONTRAVENTION_VIEW.CON_AMOUNT_DUE} > 5.00 and
Not(IsNull({RPT_ENTITY_VIEW.ENT_PRIMARY_ID})) and
Not (IsNull({BannerHolds.PUID})) and
(AAA.ZZZ <> BBB.ZZZ or
AAA.YYY <> BBB.YYY or
AAA.XXX <> BBB.XXX)
using the parenthesis, but it doesn't seem to matter in Crystal. Am I completely missing something or is this intentional?  Is there a way around repeating the AND block for each OR statement?
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Feb 2010 at 7:20am
You can add the Parenthed OR statement as in SQL (last example) so there is something else amiss in your statement.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 03 Feb 2010 at 7:29am
Have you looked at the SQL query that CR creates?  Also the second block will 'and' the 'AAA.ZZZ <> BBB.ZZZ' but the next two statements will be 'ORed' with the rest of the statements.  Where as the last block the three 'OR' statements will be 'ANDed' with the rest of the statments.
As far as performance, that is going to be a tough call depending on the joins and amount of data having to be processed.
 
Lots of luck.
IP IP Logged
degraves
Newbie
Newbie


Joined: 03 Feb 2010
Online Status: Offline
Posts: 2
Quote degraves Replybullet Posted: 03 Feb 2010 at 7:36am
Thank you both. 
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