如何解决DAY SQL的总和和组输出
我无法通过别名Gross_Demand和Units进行引用。
,(CASE WHEN CONCAT(',',post_event_list,') LIKE '%,1,%' THEN SPLIT(item,";")[safe_offset(3)] END) Gross_Demand,";")[safe_offset(2)] END) Units
解决方法
故意不给您具体的答案,但我会这样构造您的查询:
-- Declare your variables
DECLARE StartDate...
with hits as (
-- select what you need from your hits table,filter and unnest here
),products as (
-- select and filter what you need from your products table here
),joined as (
-- join the two sources together and do any additional filtering
select
date,visits,orders,gross_demand,units,etc...
from hits
join products
),calcs as (
select
*,gross_demand*units as revenue,orders/visits * 100 as conversion_pct,gross_demand*units/visits as revenue_per_visit
from joined
)
select * from calcs
将逻辑分解为若干步骤/块通常会使事情变得更容易。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。