Skip to main content

How to filter an advanced query with a Boolean parameter


I need a SQL query with a Boolean parameter. I want to add a condition if the parameter is true.

For example, I want to add the condition following condition if HideClosedProjects is true.



A Boolean value becomes 0 or 1 in the database.

For the example, modify the SQL query by adding the input parameter HideClosedProjects with type Boolean. Then, add a condition to the query as shown below:

SELECT (...)
FROM (...)
    (HideClosedProjects = 0 or
        {VW_F_CAPEX_TRNS}.[PROJECT_STATUS] != ‘Closed’)

If HideClosedProjects is false, the SQL engine never evaluates the second part of the condition.

  • Was this article helpful?