Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8248195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:06:40+00:00 2026-06-07T23:06:40+00:00

I am making an rdl report and I have three check-boxes that if checked

  • 0

I am making an rdl report and I have three check-boxes that if checked need to alter my WHERE statement. If none are checked the result should only match by date range. If one or more are checked it needs to return the fields that match the variables corresponding string.

WHERE 
(EffectiveDate BETWEEN @StartDate AND @EndDate) 
AND (((@IncludeSEWPrefix = 1 AND PrefixId = 'SEW') OR @IncludeSEWPrefix = 0)
AND ((@IncludePAWPrefix = 1 AND PrefixId = 'PAW') OR @IncludePAWPrefix = 0)
AND ((@IncludeRPLPrefix = 1 AND PrefixId = 'RPL') OR @IncludeRPLPrefix = 0)) 

My code so far works when none are checked and when one is checked, but returns nothing when more than one check-box has been checked. So to try and fix this I altered the code to this

WHERE 
(EffectiveDate BETWEEN @StartDate AND @EndDate) 
AND ((((@IncludeSEWPrefix = 1 AND PrefixId = 'SEW') OR @IncludeSEWPrefix = 0)
OR ((@IncludePAWPrefix = 1 AND PrefixId = 'PAW') OR @IncludePAWPrefix = 0)
OR ((@IncludeRPLPrefix = 1 AND PrefixId = 'RPL') OR @IncludeRPLPrefix = 0)))

Which resulted in all rows being returned no matter what was selected. Can someone tell me where I am going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:06:42+00:00Added an answer on June 7, 2026 at 11:06 pm

    I believe this is the correct rearrangement. Trickier problem than it first appears. The issue was seperating lines like ((@IncludeSEWPrefix = 1 AND PrefixId = 'SEW') OR @IncludeSEWPrefix = 0) with AND meant that if two includes were true, a row would need to have both PrefixId‘s, which can’t happen. And if you separated them with OR, then having just one include false, means that every row will pass. So instead, check that a row has the prefix of any that are included, otherwise all includes have to be off.

    WHERE EffectiveDate BETWEEN @StartDate AND @EndDate
    AND 
    (
        (@IncludeSEWPrefix = 1 AND PrefixId = 'SEW') OR
        (@IncludePAWPrefix = 1 AND PrefixId = 'PAW') OR 
        (@IncludeRPLPrefix = 1 AND PrefixId = 'RPL') OR
        (@IncludeSEWPrefix = 0 AND @IncludePAWPrefix = 0 AND @IncludeRPLPrefix = 0)
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Making game of life I need to a have a grid that is 30x20
Making a flash page that can cycle through these three images on mouseclick. For
Making a link with javascript:void(0) violate the W3C standard. I need to have a
Making a ship game because I am incredibly original.. With that aside, I have
Making a word document of our network set-up. We have about 7 servers and
Making an adobe flex ui in which data that is calculated must use proprietary
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
Making websites that appear correctly in IE is a big problem. Is there any
Making a mobile friendly site, I have a single field and a submit button.
Making an Flex App. Just wondering if anyone has created something that fits automatically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.