Search code examples
google-bigquerypybigquery

Where clause with 80% true Condition in BigQuery?


I have to put a query in BigQuery where we have 100 conditions( in where clause). I want, if any of 80+ conditions are true then it should fetch the data. Is that possible in Big Query?


Solution

  • Below is for BigQuery Standard SQL

    select *
    from `project.dataset.table`
    where (
      select countif(condition)
      from unnest([
        condition1,
        condition2,
        condition3,
        . . .
        condition99,
        condition100
      ]) condition
    ) >= 80