Skip to content
Advertisement

Bigquery – How to filter records with certain condition

I’m trying to write SQL (in BigQuery) the following in order to get a result that satisfies the following conditions. for ex: my table contains the following data

I want to filter out records where it contains only value as “p” from the table. The expected result would be

I have tried with the following query but it returns other rows as well (1,p and 1,oo)

can someone help how to achieve this using bigquery ?

Advertisement

Answer

You can count the distinct values for every id

| id |
| -: |
|  2 |
|  6 |

db<>fiddle here

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement