大数据全系列 教程
1869个小节阅读:465.4k
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
xxxxxxxxxx
pl day col ct
website 2022-01-20 pv1 233
website 2022-01-20 pv2 82
website 2022-01-20 pv3 18
website 2022-01-20 pv4 7
将行转列:
xxxxxxxxxx
pl day pv1 pv2 pv3 pv4 pv5_10 pv10_30 pv30_60 pv60_plus
website 2022-01-20 233 0 0 0 0 0 0 0
website 2022-01-20 0 82 0 0 0 0 0 0
website 2022-01-20 0 0 18 0 0 0 0 0
website 2022-01-20 0 0 0 7 0 0 0 0
all 2022-01-20 233 0 0 0 0 0 0 0
all 2022-01-20 0 82 0 0 0 0 0 0
all 2022-01-20 0 0 18 0 0 0 0 0
all 2022-01-20 0 0 0 7 0 0 0 0
sql实现:
xxxxxxxxxx
select pl,`day`,ct as pv1,0 as pv2,0 as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv1' union all
select pl,`day`,0 as pv1,ct as pv2,0 as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv2' union all
select pl,`day`,0 as pv1,0 as pv2,ct as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv3' union all
select pl,`day`,0 as pv1,0 as pv2,0 as pv3,ct as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv4' union all
select pl,`day`,0 as pv1,0 as pv2,0 as pv3,0 as pv4,ct as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv5_10' union all
select pl,`day`,0 as pv1,0 as pv2,0 as pv3,0 as pv4,0 as pv5_10,ct as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv10_30' union all
select pl,`day`,0 as pv1,0 as pv2,0 as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,ct as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv30_60' union all
select pl,`day`,0 as pv1,0 as pv2,0 as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,ct as pv60_plus
from stats_view_depth_tmp where col='pv60_plus' union all
select 'all' as pl,`day`,ct as pv1,0 as pv2,0 as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv1' union all
select 'all' as pl,`day`,0 as pv1,ct as pv2,0 as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv2' union all
select 'all' as pl,`day`,0 as pv1,0 as pv2,ct as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv3' union all
select 'all' as pl,`day`,0 as pv1,0 as pv2,0 as pv3,ct as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus
from stats_view_depth_tmp where col='pv4' union all
select 'all' as pl,`day`,0 as pv1,0 as pv2,0 as pv3,0 as pv4,ct as pv5_10,0 as pv10_30,0 as pv30_60,0 as pv60_plus from stats_view_depth_tmp where col='pv5_10' union all
select 'all' as pl,`day`,0 as pv1,0 as pv2,0 as pv3,0 as pv4,0 as pv5_10,ct as pv10_30,0 as pv30_60,0 as pv60_plus from stats_view_depth_tmp where col='pv10_30' union all
select 'all' as pl,`day`,0 as pv1,0 as pv2,0 as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,ct as pv30_60,0 as pv60_plus from stats_view_depth_tmp where col='pv30_60' union all
select 'all' as pl,`day`,0 as pv1,0 as pv2,0 as pv3,0 as pv4,0 as pv5_10,0 as pv10_30,0 as pv30_60,ct as pv60_plus from stats_view_depth_tmp where col='pv60_plus';