【问题标题】:Pgsql to SnowflakePostgresql 到雪花
【发布时间】:2023-01-24 02:52:15
【问题描述】:

我很难将以下 postgres 代码转换为雪花。请有经验的人帮我解决这个问题好吗?

  1. 选择 count(distinct inv.invite_id) filter (where invite_opened) "Invites Opened"

  2. 选择 b.onboard_initial_agents_invited_at 然后是“Initial Agents Invited”时的情况

    谢谢,

    哈比

    对于第一个,我尝试了这个,但没有用:

    选择 count(distinct inv.invite_id) case when 'invites_opened' THEN 1 END as "Invites Opened"

【问题讨论】:

    标签: sql postgresql snowflake-cloud-data-platform


    【解决方案1】:

    select count(distinct inv.invite_id) filter (where invite_opened) "Invites Opened" 是条件聚合:

    select count(distinct CASE WHEN invite_opened THEN inv.invite_id END) AS "Invites Opened"
    

    它也可以通过使用 COUNT_IF(但没有 DISTINCT)来实现:

    select count_if(invite_opened) AS "Invites Opened"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-22
      • 2021-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多