数据结果如下:
月份 总活跃用户数 1天 2-4天 5-9天 低级活跃 中级活跃 高级活跃 201101 32882523 21212935 9303626 1240819 16409668 8292009 8180846为给报表的图形提供数据,除了柱状图可以这样提供一行多列的数据. 当饼图的数据是单列多行.
如下
月份 类型, 人数
201101低级活跃 16409668
201101中级活跃 16409668
201101高级活跃 16409668
那么怎么把列转成行呢? 网上大把是把行转成多列.
select a.Monthno,b.fid,
decode(b.fid,'低级活跃',a.lowerActive,
'中级活跃',a.MideActive,
'高级活跃',a.HightActive,
) as LevelActive,
from
(
select Monthno ,
SUM(thismonthacttotal) AllActiveUser,
SUM(OneDayTotal) onedaytotal,
SUM(TwoFourDayTotal) TwoFourDayTotal,
SUM(FiveNineDayTotal) FiveNineDayTotal,
SUM(OneFourTimeTotal) lowerActive,
SUM(FiveNineTimeTotal) MideActive,
SUM(MoreTenTimeTotal) HightActive
from VW_Activity_Stat
where 1 = 1 and Monthno=201101
GROUP BY Monthno
) a,
(
select '低级活跃' fid from dual
union all
select '中级活跃' fid from dual
union all
select '高级活跃' fid from dual
) b