记一次需求的巧妙解法

create table tmp.zhibiao_data_luo_table as

select dt,

      oneway_roundway,

      platform,

      sort,

      click_exposure,

      explode_index index,

      traceid

from

(

  select dt,

        oneway_roundway,

        platform,

        sort,

        index,

        click_exposure,

        content,

        traceid

  from(

      select dt,

          oneway_roundway,

          platform,

          sort,

          max(index) index,

          click_exposure,

        traceid

      from f_analysis.dom_click_exposure_info

      where oneway_roundway='oneWay' and dt='2020-07-16' and click_exposure='exposure'

    group by dt,oneway_roundway,platform,sort,click_exposure,traceid

    )A join (

      select

        num_rank,

        collect_set(num_rank) over(rows between unbounded preceding and current row) as content

      from (select

            row_number() over() as num_rank

            from f_wide.wide_order

            where dt='20200720'

            limit 250

      )tmp

  )B on A.index=B.num_rank

)A lateral view explode(content) tmp as explode_index

你可能感兴趣的:(记一次需求的巧妙解法)