• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
机灵小不懂
博客园    首页    新随笔    联系   管理    订阅  订阅

Used Query

---  查询 look back 6 days logic period_key.

select s.store_id, i.upc, sf.period_key from JNJ_CASINO_HF.spd_fact_pivot sf 
inner join JNJ_CASINO_HF.olap_store s on s.store_key=sf.store_key
inner join JNJ_CASINO_HF.olap_item i on i.item_key=sf.item_key
inner join (select s1.store_id, i1.upc from JNJ_CASINO_HF.spd_fact_pivot sf1
inner join JNJ_CASINO_HF.olap_store s1 on s1.store_key=sf1.store_key
inner join JNJ_CASINO_HF.olap_item i1 on i1.item_key=sf1.item_key
group by s1.store_id, i1.upc having (Sum("POG_IND")>0 or Sum("Ranged Indicator")>0)) a on a.store_id=s.store_id and a.upc=i.upc
where ("Ranged Indicator" is null or "POG_IND" is null)
and sf.period_key >= (select min(period_key) from JNJ_CASINO_HF.spd_fact_pivot where "Ranged Indicator" is not null or "POG_IND" is not null) 
and sf.period_key <= (select max(period_key) from JNJ_CASINO_HF.spd_fact_pivot where "Ranged Indicator" is not null or "POG_IND" is not null) 
group by s.store_id, i.upc, sf.period_key 
order by s.store_id, i.upc, sf.period_key
limit 30

posted @ 2016-10-09 15:30  机灵小不懂  阅读(168)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3