sql - 在 Google Big Query 中执行简单分组
问题描述
我对谷歌大查询有最简单的查询,它不断返回错误
Grouping by expressions of type STRUCT is not allowed
我只是想从两个位置选择电子邮件列表,将它们合并到一个 cte 中,并计算 cte 中的频率以识别重复项。
这应该很容易 - 我错过了什么?
with a as (select properties.email as email, 'loc1' as tag from `loc1.contacts`),
b as (select properties.email as email, 'loc2' as tag from `loc2.contacts`),
c as (
select * from a
union all
select * from b
)
select email, count(email) from c group by 1
sample data:
email/tag
bob@email.com/loc1
bob@email.com/loc2
expected results:
email/count
bob@email.com/2
解决方案
看起来我需要添加 .value 才能实际获取电子邮件字段的值,以下查询按预期工作
with a as (select properties.email.value as email, 'loc1' as tag from `loc1.contacts`),
b as (select properties.email.value as email, 'loc2' as tag from `loc2.contacts`),
c as (
select * from a
union all
select * from b
)
select email, count(email) from c group by 1
推荐阅读
- python - 在python中读取没有锁定的txt文件
- reactjs - Material ui单选按钮组在选择时不改变
- elasticsearch - 术语查询在弹性搜索中不起作用,其中包含空间的值
- python - 根据条件将 pyspark 数据帧拆分为多个数据帧
- c# - 模拟:异步方法的 SetReturnsDefault 始终返回 null
- hashicorp-vault - Vault (HashiCorp) - curl 相当于“vault read”
- java - 将订单代码转换为预购和后购
- image - 去除身份证上的卷曲线
- oracle - 更改 USER_ROLES_PRIVS 表中公共列的脚本
- javascript - 用于反应类/组件的 Vanilla JavaScript