BigQuery no matching signature when trying to filter rows based on on list of integers

Joh*_*ews 1 sql google-bigquery

I am trying to extract certain rows where the column Code matches one of the integers in a list:

SELECT DISTINCT *
FROM `detail_table`
WHERE Date BETWEEN '2019-03-12' AND '2019-03-15'
AND Code IN UNNEST([36516, 152])
Run Code Online (Sandbox Code Playgroud)

However, I get the error:

google.api_core.exceptions.BadRequest: 400 No matching signature for operator IN UNNEST for argument types: STRING, ARRAY

What am I supposed to do to make it work? When its strings then it works fine, but I have to filter on integers.

Mik*_*ant 5

在下面使用

#standardSQL
SELECT DISTINCT *
FROM `project.dataset.detail_table`
WHERE `date` BETWEEN '2019-03-12' AND '2019-03-15'
AND Code IN UNNEST(['36516', '152'])  
Run Code Online (Sandbox Code Playgroud)

要么

#standardSQL
SELECT DISTINCT *
FROM `project.dataset.detail_table`
WHERE `date` BETWEEN '2019-03-12' AND '2019-03-15'
AND CAST(Code AS INT64) IN UNNEST([36516, 152])   
Run Code Online (Sandbox Code Playgroud)

甚至只是(取决于您的情况)

#standardSQL
SELECT DISTINCT *
FROM `project.dataset.detail_table`
WHERE `date` BETWEEN '2019-03-12' AND '2019-03-15'
AND Code IN ('36516', '152')
Run Code Online (Sandbox Code Playgroud)