Skip to content
Advertisement

Equivalent of string contains in google bigquery

I have a table like as shown below

enter image description here

I would like to create two new binary columns indicating whether the subject had steroids and aspirin. I am looking to implement this in Postgresql and google bigquery

I tried the below but it doesn’t work

I expect my output to be like as shown below

enter image description here

Advertisement

Answer

Below is for BigQuery Standard SQL

if to apply to sample data from your question – result is

Note: instead of simple LIKE ending with lengthy and redundant text – I am using LIKE on steroids – which is REGEXP_CONTAINS

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