【问题标题】:How to replace Qualify key word in Big Query如何在 Bigquery 中替换 Qualify 关键字
【发布时间】:2021-09-18 08:45:25
【问题描述】:

BigQuery 中的等价条件是什么。我的 TD 查询如下,我正在尝试形成一个等效的 BQ

select cast(pol.ORDER as int) as target
  from db.porder po
  inner join db_line pol
    on po.po_nbr = pol.po_nbr
    and po.order_date = pol.order_date
qualify row_number() over (partition by po.po_nbr order by po.order_date desc) = 1
  where 
  po.po_nbr = '12345'
  and pol.LINE_NBR = 1

【问题讨论】:

  • qualify 等价于 qualify。不过,您需要修复您的查询,以便 wherequalify 之前。

标签: sql google-bigquery teradata


【解决方案1】:

假设您的查询在 TD 中有效 - 请在 BQ 中尝试以下

select cast(pol.ORDER as int) as target
  from db.porder po
  inner join db_line pol
    on po.po_nbr = pol.po_nbr
    and po.order_date = pol.order_date
  where 
  po.po_nbr = '12345'
  and pol.LINE_NBR = 1
  qualify row_number() over (partition by po.po_nbr order by po.order_date desc) = 1

在 BQ 中了解 QUALIFY clause

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    • 1970-01-01
    • 2013-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多