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 8016409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:31:57+00:00 2026-06-04T20:31:57+00:00

I need a parametrized crosstab query. I mostly worked it out except for parameters

  • 0

I need a parametrized crosstab query. I mostly worked it out except for parameters part.
I have four parameters to apply: ChangeID and variant1, variant2 and variant3.
ChangeID is mandatory, it needs to be filled in by the user. Variant1..3 are optional: either user fills one to three variants or (if variant1 is null) the default should be used.

Default is an alternative of predefined variants, actual filled in variants should be applied as alternative too.

I thought of something like this:

PARAMETERS ChangeID Text (7), variant1 Text (10), variant2 Text (10), variant3 Text (10);
TRANSFORM Sum([Qty]*[inout]) AS QtyInOut
SELECT MatByOrder.CHpoint, MatByOrder.PN, MatByOrder.Description, MatByOrder.Price, MatByOrder.UoM
FROM Variants INNER JOIN MatByOrder ON Variants.BO = MatByOrder.BO

WHERE 
    (MatByOrder.CHpoint=ChangeID) AND 
    (IIF(isNull([variant1]); 
        (Variants.Variant="B100") OR (Variants.Variant="B200") OR (Variants.Variant="B300") OR (Variants.Variant="B400") OR (Variants.Variant="B500");
        (Variants.Variant=[variant1]) OR (Variants.Variant=[variant2]) OR (Variants.Variant=[variant3])
       )
    )

GROUP BY MatByOrder.CHpoint, MatByOrder.PN, MatByOrder.Description, MatByOrder.Price, MatByOrder.UoM

but it doesn’t work. The problem is of course in IIF in WHERE clause.

What is the correct way to accomplish this?

  • 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-04T20:31:59+00:00Added an answer on June 4, 2026 at 8:31 pm

    This should work:

    WHERE 
        (MatByOrder.CHpoint=ChangeID) AND 
        (
           ( ([variant1] IS NULL) AND (Variants.Variant IN ('B200', 'B300', 'B400', 'B500')) )
           OR    
           ( ([variant1] IS NOT NULL) AND (Variants.Variant IN ([variant1], [variant2], [variant3])) )
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an abstract test class that has two type parameters. I need to
I have the following Query and i need the query to fetch data from
I have some classes which are parameterized via their constructor. I need to provide
Need to port data in sql table I have a master table with columns
I have a DataTable in memory that I need to dump straight into a
I need to initialize an array of objects of a parametrized constructor . How
i need to make a select to find out X then i need to
I try to override my parametrized method in scala, I have an abstract class
As i previously discovered, SQLieParameter (parametrized query) can't be used for create table in
I have recently leaped into parametrized queries in SQL. I am now getting a

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.