BQL では、WHERE 句または HAVING 句のいずれかで範囲指定された集計を参照できないことに気付きました。例えば:
% bq query 'SELECT fullName, COUNT(children.name) WITHIN RECORD as numChildren FROM [persons.person]'
+---------------+-------------+
| fullName | numChildren |
+---------------+-------------+
| John Doe | 2 |
| Mike Jones | 3 |
| Anna Karenina | 0 |
+---------------+-------------+
% bq query 'SELECT fullName, COUNT(children.name) WITHIN RECORD as numChildren FROM [persons.person] WHERE numChildren > 0'
BigQuery error in query operation: Field 'numChildren' not found in table 'persons.person'.
% bq query 'SELECT fullName, COUNT(children.name) WITHIN RECORD as numChildren FROM [persons.person] HAVING numChildren > 0'
BigQuery error in query operation: Invalid use of HAVING clause. HAVING should be used only when non scoped aggregations are present. Non aggregating queries should use WHERE instead
WHERE 句でグループ レベルの集計を許可しない理由と、WHERE 句または HAVING 句のいずれかでテーブル レベルの集計を許可しない理由を理解していますが、範囲指定された集計ができる理由は思いつきません。 WHERE または HAVING 句には表示されません。誰でも理由を提供できますか?