0
votes

I try to run this SQL query:

WITH is_positive AS (SELECT x>0 FROM UNNEST([5, -2, 3, 6, -10, -7, 4, 0]) AS t(x))
SELECT COUNTIF(is_positive); 

but I get an error

Syntax error: Expected ")" but got "(" [at 1:79]

Can you help me to figure out where the problem is?

Where to test: https://console.cloud.google.com/bigquery?project=root-melody-302907

1

1 Answers

0
votes

Try below fixed version

WITH is_positive AS (
    SELECT x > 0 flag
    FROM UNNEST([5, -2, 3, 6, -10, -7, 4, 0]) AS x
)
SELECT COUNTIF(flag)
FROM is_positive