0
votes

I am looking for aggregate function (sum/avg) per table from the below like query.

SELECT sum(qty) FROM TABLE_QUERY([black-resource-174911:owner],'table_id CONTAINS "sales2017"') where category='shoes'

I am expecting:

sum table

100 sales2017W1 200 sales2017W2 250 sales2017W3

Is there any such option in BigQuery? Appreciate help.

1

1 Answers

2
votes

Below is for BigQuery Standard SQL

#standardSQL
SELECT SUM(qty) AS sum, _TABLE_SUFFIX AS table 
FROM `black-resource-174911.owner.sales2017*`
WHERE category = 'shoes'
GROUP BY table