Use switch to alter query

I'm using a switch to alter a query - so that I can only show a set f records based on a column being = true.

However, I'd liek to adjust this code so that if the switch is set to false, it shows me all records - not just the false records.

I'm not quite sure how to do this, and I am hoping someone can help me.


SELECT esrs_requirements.requirement_title, esrs_requirements.requirement_code, sector_issues.sector_issue, link_sector_issues_with_esrs_requirements.sector_issue_id AS "Sector Issue ID", esrs_index.esrs_number, link_sector_issues_with_esrs_requirements.required
FROM link_sector_issues_with_esrs_requirements
LEFT JOIN esrs_requirements ON link_sector_issues_with_esrs_requirements.esrs_requirement_id =
LEFT JOIN sector_issues ON link_sector_issues_with_esrs_requirements.sector_issue_id =
LEFT JOIN esrs_index ON esrs_requirements.esrs_id =
WHERE link_sector_issues_with_esrs_requirements.sector_issue_id = {{select_sector_issues_esrs_matching.value}} AND link_sector_issues_with_esrs_requirements.required = *{{switch_esrs_required.value}}*
ORDER BY link_sector_issues_with_esrs_requirements.date_updated

Have you used a CASE statement?

Hi Scott,
I haven't - I will look into that and see if that works for me,
thank you!