蜂巢查询以找到转化率

发布于 2025-01-28 08:25:58 字数 535 浏览 3 评论 0原文

我正在尝试使用Hive的查询,但它无法正常工作。

select
  (
    (
      select
        count(*)
      from
        click_streaming
      where
        page_id= 'e7bc5fb2-1231-11eb-adc1-0242ac120002'
        and is_page_view = 'Yes'
    ) / (
      select
        count(*)
      from
        click_streaming
      where
        button_id= 'fcba68aa-1231-11eb-adc1-0242ac120002'
        and is_button_click= 'Yes'
    )
  ) as conversion_ratio;

错误我正在得到:无法识别“选择”“计数”附近的输入(“在表达式规范中,

我基本上是在尝试获取查看页面的客户的转换率,然后单击按钮预订驾驶室。

I am trying this query in Hive and it's not working.

select
  (
    (
      select
        count(*)
      from
        click_streaming
      where
        page_id= 'e7bc5fb2-1231-11eb-adc1-0242ac120002'
        and is_page_view = 'Yes'
    ) / (
      select
        count(*)
      from
        click_streaming
      where
        button_id= 'fcba68aa-1231-11eb-adc1-0242ac120002'
        and is_button_click= 'Yes'
    )
  ) as conversion_ratio;

Error I am getting: cannot recognize input near 'select' 'count' '(' in expression specification

I am basically trying to get conversion rate of customers who view the page and click the button to book a cab.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁我热情 2025-02-04 08:25:58

这不是语法的方式。只需加入他们的工作,或使用案件来完成工作即可。

select 
sum(case when page_id= 'e7bc5fb2-1231-11eb-adc1-0242ac120002' and is_page_view = 'Yes' then 1 else 0 end) /
sum(case when button_id= 'fcba68aa-1231-11eb-adc1-0242ac120002' and is_button_click= 'Yes' then 1 else 0 end) conv_ratio
FROM 
 click_streaming

或者您可以重复使用SQL,但您必须加入它们

select c1/c2
from (
select
        count(*) c1
      from
        click_streaming
      where
        page_id= 'e7bc5fb2-1231-11eb-adc1-0242ac120002'
        and is_page_view = 'Yes') rs
join (select
        count(*) c2
      from
        click_streaming
      where
        button_id= 'fcba68aa-1231-11eb-adc1-0242ac120002'
        and is_button_click= 'Yes')rs2

This is not how the syntax can be. Just join them both or use a case when to do your job.

select 
sum(case when page_id= 'e7bc5fb2-1231-11eb-adc1-0242ac120002' and is_page_view = 'Yes' then 1 else 0 end) /
sum(case when button_id= 'fcba68aa-1231-11eb-adc1-0242ac120002' and is_button_click= 'Yes' then 1 else 0 end) conv_ratio
FROM 
 click_streaming

or you can reuse your SQLs but you got to join them

select c1/c2
from (
select
        count(*) c1
      from
        click_streaming
      where
        page_id= 'e7bc5fb2-1231-11eb-adc1-0242ac120002'
        and is_page_view = 'Yes') rs
join (select
        count(*) c2
      from
        click_streaming
      where
        button_id= 'fcba68aa-1231-11eb-adc1-0242ac120002'
        and is_button_click= 'Yes')rs2
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文