BigQuery: Subselect not allowed in SELECT clause

\n\n

I used the following query in Google BigQuery:

\n\n
SELECT count_in_bin/(SELECT SUM(count_in_bin) FROM [table])\nFROM [table]\n
\n\n

Then I get

\n\n
\n

error:Query Failed\n Error: Subselect not allowed in SELECT clause

\n
\n\n

Solution:

BigQuery Standard SQL

\n\n
#standardSQL\nSELECT \n  count_in_bin, \n  count_in_bin / total AS ratio\nFROM `project.dataset.table`, \n(SELECT SUM(count_in_bin) total FROM `project.dataset.table`)\n

Mike-Barn

posted on

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds