Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: OuterJoin in WhereClause(Record Selection Formula) Post Reply Post New Topic
Author Message
ACheeseman
Newbie
Newbie


Joined: 16 Nov 2010
Online Status: Offline
Posts: 1
Quote ACheeseman Replybullet Topic: OuterJoin in WhereClause(Record Selection Formula)
    Posted: 16 Nov 2010 at 4:14am
I have this SQL (below) and i want to use it in crystal,
the point is to show all the pro_code and details (i clipped most for ease of posting it here) and i use the summary distinct count on the cust_code to display how many customers if any are using this pro_code
Basically i want to use the (+) in my record select formula
SELECT
   "INF_DETAI"."PRO_CODE",
   "INF_DETAI"."PRO_DES",
   "INF_DETAI"."DOC_DIR,
   "CRR_HEAD"."CUST_CODE"
FROM
    CRR_HEAD,
    INF_DETAI
WHERE
   "CRR_HEAD"."PRO_CODE"(+) = "INF_DETAI"."PRO_CODE" AND
   "CRR_HEAD"."COMPANY_CODE"(+) = 'W1'
GROUP BY
   "INF_DETAI"."PRO_CODE"



Here is a extract that shows that it will return 0 cust_codes if it doesn't match the PRO_CODE with a Customer's PRO_CODE
SELECT
   "INF_DETAI"."PRO_CODE",
    COUNT(DISTINCT "CRR_HEAD"."CUST_CODE")
FROM
    CRR_HEAD,
    INF_DETAI
WHERE
   "CRR_HEAD"."PRO_CODE"(+) = "INF_DETAI"."PRO_CODE" AND
   "CRR_HEAD"."COMPANY_CODE"(+) = 'W1'
GROUP BY
   "INF_DETAI"."PRO_CODE"



Edited by ACheeseman - 16 Nov 2010 at 4:17am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 17 Nov 2010 at 6:34am
Crystal will not use this particular syntax.  However, there is a way to get the same result.
 
1.  For the first part of your Where clause, go to Links tab of the Database Expert and right-click on the join between the tables.  Select "Link Options" and change the link to an outer join.
 
2.  For the Second part of your Where clause, go to the Select Expert.  If you don't have anything there yet, select your Company_Code field.  Click on "Show Formula" and then "Formula Editor" and enter the following:
 
(IsNull({CRR_HEAD.COMPANY_CODE}) or {CRR_HEAD.COMPANY_CODE} = 'W1')
 
Note the parentheses at the beginning and end of this.  If you have any other selection criteria besides this, you MUST have the parens in order for this to work correctly.
 
-Dell
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.031 seconds.