美文网首页
既想聚合count(1) over(partition by a

既想聚合count(1) over(partition by a

作者: 大道至简_6a43 | 来源:发表于2020-06-30 22:42 被阅读0次

    select

      concat(act_dep_city,'_',act_arr_city) as key,

      concat(round(cast(city_line_num as float)/cast(city_all_num as float)*100,1),'%','-',rn) as value

    from(

      select

          act_dep_city,

          act_arr_city,

          city_all_num,

          count(1) as city_line_num,

          row_number() over(partition by act_arr_city order by count(1) desc) as rn

      from(

          select

            act_dep_city,

            act_arr_city,

            count(1) over(partition by act_arr_city) as city_all_num

          from

            f_wide.wide_order where dt='20200530'

      )A group by act_dep_city,act_arr_city,city_all_num

    )A

    相关文章

      网友评论

          本文标题:既想聚合count(1) over(partition by a

          本文链接:https://www.haomeiwen.com/subject/rvofqktx.html