[英]BigQuery - Unique Customers in Sales Table
select count(distinct customer)
from sales
编辑:
最初的问题是关于计算唯一身份客户。 上面的查询将做到这一点。
如果你想从客户的第一次访问记录中查看其他字段,那么你可以像这样使用 window function:
select store, customer, visit_date
from (
select store, customer, visit_date,
row_number() over (partition by customer order by visit_date) n
from sales
)
where n = 1
select count(distinct customer) from sales
与唯一客户一起查找日期
Select store, customer, minimum (visit_date) group by customer, store
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.