一般SQL问题(大查询)-删除每个客户不同日期后的行
我想删除所有的客户点击,我看到我的网站后,他们已经注册。但是,并非所有客户都会在同一天注册,因此我不能简单地在特定日期进行筛选。我有一个注册指示符1或0,然后是一个命中时间戳,以及特定客户的唯一指示符。我试过这个:一般SQL问题(大查询)-删除每个客户不同日期后的行,sql,google-bigquery,Sql,Google Bigquery,我想删除所有的客户点击,我看到我的网站后,他们已经注册。但是,并非所有客户都会在同一天注册,因此我不能简单地在特定日期进行筛选。我有一个注册指示符1或0,然后是一个命中时间戳,以及特定客户的唯一指示符。我试过这个: rank() over (partition by customer_id, registration_ind order by hit_timestamp asc) rnk 然而,这仍然是按客户划分的,不能满足我的需要 需要帮忙吗 谢谢这是你想要的吗 select t.* fro
rank() over (partition by customer_id, registration_ind order by hit_timestamp asc) rnk
然而,这仍然是按客户划分的,不能满足我的需要
需要帮忙吗
谢谢这是你想要的吗
select t.*
from (select t.*,
min(case when registration_ind = 1 then hit_timestamp end) over (partition by customer_id) as registration_timestamp
from t
) t
where registration_timestamp is null or
hit_timestamp < registration_timestamp;
它返回第一个注册时间戳之前的所有行。这是您想要的吗
select t.*
from (select t.*,
min(case when registration_ind = 1 then hit_timestamp end) over (partition by customer_id) as registration_timestamp
from t
) t
where registration_timestamp is null or
hit_timestamp < registration_timestamp;
它返回第一个注册时间戳之前的所有行。请提供示例数据和所需结果。请提供示例数据和所需结果。