- #1
DaveC426913
Gold Member
- 22,989
- 6,665
- TL;DR Summary
- Why is this search query warning me about and/or indentation?
I'm constructing a search query in a proprietary database and I'm getting a warning about my use of ands and ors.
I've included the search as pseudocode. I have inserted square brackets whereas the actual query only uses indents (which I cannot get my head around).
What I am expecting to get is:
Here is my concern:
When I test this the system responds with
"You should not have an and and an or at the same indent level."
Is my search not well-formed?
Can I rectify the problem simply by indenting the entire section after the third and that contains all the ors? (That would require an initial double-indentation, i.e. and [[ )
I've included the search as pseudocode. I have inserted square brackets whereas the actual query only uses indents (which I cannot get my head around).
What I am expecting to get is:
- Enrolled members
- between ages 50 and 74 (incl.)
- who have had at least one of the following (during the specified 30 month window):
- Q code along with SOB or FOBT
- FIT
- SIG
Here is my concern:
When I test this the system responds with
"You should not have an and and an or at the same indent level."
Is my search not well-formed?
Can I rectify the problem simply by indenting the entire section after the third and that contains all the ors? (That would require an initial double-indentation, i.e. and [[ )
Code:
Member Status = Enrolled
and
Age >= 50
and
Age <= 74
and
[
Q code date is earlier than Apr 1, 2021
and
Q code date is later than Sep 30, 2018
and
[
[
SOB date is earlier than Apr 1, 2021
and
SOB date is later than Sep 30, 2018
]
or
[
FOBT date is earlier than Apr 1, 2021
and
FOBT date is later than Sep 30, 2018
]
]
]
or
[
FIT date is earlier than Apr 1, 2021
and
FIT date is later than Sep 30, 2018
]
or
[
SIG date earlier than Apr 1, 2021
and
SIG date is later than Sep 30, 2018
]