【问题标题】:how to join on if one timestamp lies between two other timestamps in snowflake如果一个时间戳位于雪花中的其他两个时间戳之间,如何加入
【发布时间】:2021-07-15 17:19:25
【问题描述】:

我在雪花中有 2 张桌子,如下所示:

  1. 表 1:播放器会话(播放器 ID、会话开始时间戳、会话 结束时间戳)-- 总共 5013 行
  2. 表 2:玩家注册(PlayerID、注册时间戳)--共 283 行

我只想要第一个表中注册时间戳(来自 table2)在 table1 的“会话开始时间戳”和“会话结束时间戳”之间的行。

如何在 Snowflake 中以这种方式加入这两个表?

【问题讨论】:

    标签: sql snowflake-cloud-data-platform


    【解决方案1】:

    你试过加入他们吗?

    select t1.*
    from table1 t1 join
         table2 t2
         on t2.signup between t1.session_start and t1.session_end;
    

    【讨论】:

    • 我不想加入 playerid 但第二个参数(t1.session_start 和 t1.session_end 之间的 t2.signup)有帮助。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2021-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多