Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OR statements in Record Selection

Status
Not open for further replies.

klaidlaw

Programmer
May 28, 2008
140
US

I am using Crystal 2008 and Oracle, I am having trouble with my record selection criteria. The formula I am using is below, basically I want the report to show records that say yes in any of these fields expect for these two (({DM_OB_MOTHER_INFORMATION.PRBC} = 1) or
({DM_OB_MOTHER_INFORMATION.PLATELETS} = 1))) or

This field has to be one (({DM_OB_MOTHER_INFORMATION.BLOOD_TRANSFUSION} = '1'). I can’t figure out why it is not working if anyone has any suggestions please let me know!! Thank you!

//RECORD SELECTION

(({DM_OB_MOTHER_INFORMATION.VACUUM} = 'Yes') or

({DM_OB_MOTHER_INFORMATION.FORCEPS} = 'Yes') or

({DM_OB_BABY_INFORMATION.SHOULDERDYSTOCIA} = 'Yes') or

(({DM_OB_MOTHER_INFORMATION.LACERATION} = '3rd degree perineal laceration') or
({DM_OB_MOTHER_INFORMATION.LACERATION} = '4th degree perineal laceration')) or

(({DM_OB_MOTHER_INFORMATION.BLOOD_TRANSFUSION} = '1') and
(({DM_OB_MOTHER_INFORMATION.PRBC} = 1) or
({DM_OB_MOTHER_INFORMATION.PLATELETS} = 1))) or

({DM_OB_MOTHER_INFORMATION.HYPERSTIMULATION} = 'Yes'))

 
Your parens were very confusing at least to me...
Try...

{DM_OB_MOTHER_INFORMATION.VACUUM} = 'Yes'
or
{DM_OB_MOTHER_INFORMATION.FORCEPS} = 'Yes'
or
{DM_OB_BABY_INFORMATION.SHOULDERDYSTOCIA} = 'Yes'
or
{DM_OB_MOTHER_INFORMATION.HYPERSTIMULATION} = 'Yes'
or
{DM_OB_MOTHER_INFORMATION.LACERATION} = '3rd degree perineal laceration'
or
{DM_OB_MOTHER_INFORMATION.LACERATION} = '4th degree perineal laceration'
or
(
{DM_OB_MOTHER_INFORMATION.BLOOD_TRANSFUSION} = '1' and
{DM_OB_MOTHER_INFORMATION.PRBC} = 1
)
or
(
{DM_OB_MOTHER_INFORMATION.BLOOD_TRANSFUSION} = '1' and
{DM_OB_MOTHER_INFORMATION.PLATELETS} = 1
)

You also may want to change the usage of nulls to default value if you expect any of these fields to contain null

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Hi,
try reordering and structuring the criteria to improve readability and maybe find a problem - as it is your code does not make clear what is needed..

Your narrative and the code do not seem to match.




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Hi,
also, try running the query that CR produces directly in SqlPlus to see if it errors out and where.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I put the code at the top into the selection criteria in Crystal and it still does not give me the correct results. When I put the code into sql with the same joins and everything as in crystal I get the correct answer. If anyone has any more suggestions please let me know! Thank you
 
Hi,
Can you post the Sql query created by CR?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
This is my SQL thank you for the help:

SELECT "CLARITY_LOC"."LOC_NAME", "PATIENT_MOTHER"."PAT_NAME", "PATIENT_MOTHER"."PAT_MRN_ID", "DM_OB_BABY_INFORMATION"."BIRTHTIME", "DM_OB_BABY_INFORMATION"."DELIVERYMETHOD", "CLARITY_LOC"."LOC_ID", "DM_OB_MOTHER_INFORMATION"."FORCEPS", "DM_OB_BABY_INFORMATION"."SHOULDERDYSTOCIA", "DM_OB_MOTHER_INFORMATION"."LACERATION", "DM_OB_BABY_INFORMATION"."INFANTCOMPLICATIONS", "DM_OB_MOTHER_INFORMATION"."PRBC", "DM_OB_MOTHER_INFORMATION"."HYPERSTIMULATION", "DM_OB_MOTHER_INFORMATION"."VACUUM", "DM_OB_MOTHER_INFORMATION"."PLATELETS", "DM_OB_MOTHER_INFORMATION"."BLOOD_TRANSFUSION"
FROM (((("CLARITY"."DM_OB_BABY_INFORMATION" "DM_OB_BABY_INFORMATION" INNER JOIN "CLARITY"."DM_OB_MOTHER_INFORMATION" "DM_OB_MOTHER_INFORMATION" ON "DM_OB_BABY_INFORMATION"."MOTHERENCOUNTERID" = "DM_OB_MOTHER_INFORMATION"."ENCOUNTERID") INNER JOIN "CLARITY"."PAT_ENC_HSP" "PAT_ENC_HSP" ON "DM_OB_MOTHER_INFORMATION"."ENCOUNTERID" = "PAT_ENC_HSP"."PAT_ENC_CSN_ID") INNER JOIN "CLARITY"."PATIENT" "PATIENT_MOTHER" ON "DM_OB_MOTHER_INFORMATION"."PATIENTID" = "PATIENT_MOTHER"."PAT_ID") INNER JOIN "CLARITY"."CLARITY_DEP" "CLARITY_DEP" ON "PAT_ENC_HSP"."DEPARTMENT_ID" = "CLARITY_DEP"."DEPARTMENT_ID") INNER JOIN "CLARITY"."CLARITY_LOC" "CLARITY_LOC" ON "CLARITY_DEP"."REV_LOC_ID" = "CLARITY_LOC"."LOC_ID"
WHERE ("DM_OB_MOTHER_INFORMATION"."VACUUM"='Yes' OR "DM_OB_MOTHER_INFORMATION"."FORCEPS"='Yes' OR "DM_OB_BABY_INFORMATION"."SHOULDERDYSTOCIA"='Yes' OR ("DM_OB_MOTHER_INFORMATION"."LACERATION"='3rd degree perineal laceration' OR "DM_OB_MOTHER_INFORMATION"."LACERATION"='4th degree perineal laceration') OR "DM_OB_MOTHER_INFORMATION"."BLOOD_TRANSFUSION"='1' OR "DM_OB_MOTHER_INFORMATION"."HYPERSTIMULATION"='Yes')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top