Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Conditional WHERE and clause help in Report Builder

I have a WHERE statement in my report that lists what I need pulled from a table,

 WHERE
  PrimaryAction= '308'
  AND PrimaryAction= '309'
  AND PrimaryAction= '307
  AND SecondaryAction= '308' 

etc.

One, it isn’t pulling just those instances. I can’t figure out what is wrong. Or is there a way to combine/condense this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Two, can I do it and have it say something like,
PrimaryAction= ‘308’ ‘309’ ‘307 , THEN ‘Yes’ so that in my report it just prints out yes if that is the case?

I tried combining them, there is Primary, Secondary , and Tertiary for the same codes but it just didn’t pull anything when I ran it. It wouldn’t even run when I tried to change to say Yes.

>Solution :

the condition can’t be 308,307 and 309 at the same time

So you can do.

but be reminded

The SQL Server AND operator takes precedence over the SQL Server OR operator (just like a multiplication operation takes precedence over an addition operation).

see SQL Logic Operator Precedence: And and Or for more example and explanation

 WHERE
  (PrimaryAction= '308'
  'OR PrimaryAction= '309'
  OR PrimaryAction= '307')
  AND SecondaryAction= '308' 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading