sql - 删除“case when”中的重复项并计算步骤之间的平均值
问题描述
我目前正在生成一个表,我试图分别通过 sessionid 对注册表单的旅程事件进行排序,以下是我的代码:
create table merchant_general.signup_step_v20 as
select a.sessionid, min(b.sentat) over (partition by b.sessionid) as pageload,
case when a.properties.itemname in ("MerchantType1", "MerchantType2", "MerchantType3", "MerchantType4") and a.properties.clicktype = 'forward' then max(a.sentat) over (partition by a.sessionid) end as SelectedMerchantType,
case when a.properties.itemname = "Continue" and a.properties.`location`= "Yeni başvuru-mağaza bilgileri" then max(a.sentat) over (partition by a.sessionid) end as EnteredNamePass,
case when a.properties.itemname = "Continue" and a.properties.`location`= "yeni başvuru-başvuru bilgileri" then max(a.sentat) over (partition by a.sessionid) end as EnteredAuthInfo,
case when a.properties.itemname = "Submit" and a.properties.`location`= "yeni başvuru-başvuruyu tamamlayın" then max(a.sentat) over (partition by a.sessionid) end as EnteredCompanyInfo
from merchant.mp_clickitem a
inner join merchant.mp_pageload b
on a.sessionid = b.sessionid
where b.dy >= date_sub(current_date,30) and b.dy <= date_sub(current_date,1) and a.dy >= date_sub(current_date,30) and a.dy <= date_sub(current_date,1)
and b.properties.pagename = "Register" and
a.properties.itemname in("MerchantType1", "MerchantType2", "MerchantType3", "MerchantType4","Continue","Submit") and a.properties.`location` != "Reset Password" and a.sessionid != ''
A列对应:sesssionID,而B列是pageload(第一步),C列是SelectedMerchantType(第二步)D列是EnteredNamePass(第三步),E列是EnteredAuthInfo(第四步),F列是输入公司信息(最后一步)。
我想计算两个连续步骤之间的微小差异,避免重复sessionID。在一个步骤完成之前不可能进行下一步,并且不同的步骤不能具有完全相同的时间戳。
解决方案
您是否尝试按 sessionID 分组?
推荐阅读
- asp.net - 从控制器检索图像路径并传递给 HttpPostedFileBase 图像模型 ASP.Net MVC
- go - 尝试在 GCP App Engine 任务队列中安排任务时出现 InvalidTaskNameError
- laravel - Laravel:事务回滚后无法插入数据库
- c# - 如何为属性模态验证编写单元测试?
- flutter - 我可以从 Pub.dev 中删除、隐藏或重命名颤振包吗?
- c++ - 比较 SQLite for C++ 中的两个结果?
- c# - 如何为非 dbo 用户注册 SQL 表依赖项
- r - 如何根据不同的值对值进行汇总,然后聚合?
- javascript - 按数组中的标签对不同的字段进行排序
- amazon-web-services - 更正此 ElastiCache CloudFormation 模板所需的审核