久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Excel中怎么實現(xiàn)動態(tài)行轉(zhuǎn)列

154次閱讀
沒有評論

共計 3019 個字符,預(yù)計需要花費 8 分鐘才能閱讀完成。

這篇文章將為大家詳細講解有關(guān) Excel 中怎么實現(xiàn)動態(tài)行轉(zhuǎn)列,文章內(nèi)容質(zhì)量較高,因此丸趣 TV 小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

查詢的 SQL 如下
ol start= 1 >

select type,ts,cn,as DECIMAL) val from ( 

select 

starttime, 發(fā)布  type,base.ts,base.cn,ifnull(t1.val,0) val 

from 

 select 

 t1.*, 

 startdate+ interval id-1 hour starttime, 

 startdate+ interval id hour endtime, 

 date_format(startdate+ interval id-1 hour, %m%d%H) ts, 

 vars.* 

 from nums ,(select ${starttime} startdate,${endtime} enddate) vars, 

 ( 

 select  mvbox_user.user_otherinfo  busidatatype,1 type, 內(nèi)容審核. 個人資料  cn union all 

 select  mvbox_user.user_baseinfo ,1, 內(nèi)容審核. 個人喜好  union all 

 select  photo_album ,1, 內(nèi)容審核. 相冊信息  union all 

 select  photo_list ,1, 內(nèi)容審核. 圖片信息  union all 

 select  music_original ,1, 內(nèi)容審核. 原唱信息  union all 

 select  music_cover ,1, 內(nèi)容審核. 翻唱信息  union all 

 select  music_accompany ,1, 內(nèi)容審核. 伴奏信息  union all 

 select  music_album ,1, 內(nèi)容審核. 音樂專輯  union all 

 select  music_video ,1, 內(nèi)容審核. 視頻信息  union all 

 select  blog_album ,1, 內(nèi)容審核. 日志與文章  union all 

 select  mvbox_user.user_baseinfo ,2, 內(nèi)容審核.MVBOX 頭像審核  

 ) t1 

 where id = TIMESTAMPDIFF(hour,startdate,enddate) 

 order by busidatatype,type,starttime 

) base join 

 select busidatatype,type,date_format(createtime, %m%d%H) ts,from audit_obj_detail 

 where createtime =${starttime} and createtime ${endtime} 

 and busitype =  mvbox  

 group by busidatatype,type,date_format(createtime, %m%d%H) 

) t1 on (base.busidatatype=t1.busidatatype and base.type=t1.type and base.ts=t1.ts) 

group by base.busidatatype,base.type,base.ts,base.cn 

union all 

select 

starttime,  審核  type,base.ts,base.cn,ifnull(t1.val,0) val 

from 

 select 

 t1.*, 

 startdate+ interval id-1 hour starttime, 

 startdate+ interval id hour endtime, 

 date_format(startdate+ interval id-1 hour, %m%d%H) ts, 

 vars.* 

 from nums ,(select ${starttime} startdate,${endtime} enddate) vars, 

 ( 

 select  mvbox_user.user_otherinfo  busidatatype,1 type, 內(nèi)容審核. 個人資料  cn union all 

 select  mvbox_user.user_baseinfo ,1, 內(nèi)容審核. 個人喜好  union all 

 select  photo_album ,1, 內(nèi)容審核. 相冊信息  union all 

 select  photo_list ,1, 內(nèi)容審核. 圖片信息  union all 

 select  music_original ,1, 內(nèi)容審核. 原唱信息  union all 

 select  music_cover ,1, 內(nèi)容審核. 翻唱信息  union all 

 select  music_accompany ,1, 內(nèi)容審核. 伴奏信息  union all 

 select  music_album ,1, 內(nèi)容審核. 音樂專輯  union all 

 select  music_video ,1, 內(nèi)容審核. 視頻信息  union all 

 select  blog_album ,1, 內(nèi)容審核. 日志與文章  union all 

 select  mvbox_user.user_baseinfo ,2, 內(nèi)容審核.MVBOX 頭像審核  

 ) t1 

 where id = TIMESTAMPDIFF(hour,startdate,enddate) 

 order by busidatatype,type,starttime 

) base join 

 select busidatatype,type,date_format(AuditTime, %m%d%H) ts,from audit_obj_detail 

 where AuditTime =${starttime} and AuditTime ${endtime} 

 and busitype =  mvbox  

 group by busidatatype,type,date_format(AuditTime, %m%d%H) 

) t1 on (base.busidatatype=t1.busidatatype and base.type=t1.type and base.ts=t1.ts) 

group by base.busidatatype,base.type,base.ts,base.cn 

) t1 ; 

由于這個 SQL 已然比較復(fù)雜,再加動態(tài)行轉(zhuǎn)列, 可讀性幾乎就沒有了.

這個 SQL 查詢的結(jié)果大致如下。

其中 type 可能是發(fā)布或者審核.

ts 表示月 日 和小時

cn 表示模塊類型

val 表示數(shù)量.

將這個結(jié)果導(dǎo)入至 Excel

選擇插入, 數(shù)據(jù)透視表

然后將 ts 設(shè)置為列標簽, 這樣 ts 就由行變成列顯示

cn 和 type 作為行標簽.

val 作為顯示數(shù)值

然后選擇視圖 - 凍結(jié)窗格 - 凍結(jié)首列   方便觀看數(shù)據(jù)

可以看到如下結(jié)果

完全符合動態(tài)行轉(zhuǎn)列的需求, 并且可以排序和篩選. 太強大了.

關(guān)于 Excel 中怎么實現(xiàn)動態(tài)行轉(zhuǎn)列就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-03發(fā)表,共計3019字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 博爱县| 虹口区| 贺兰县| 张家港市| 加查县| 海兴县| 根河市| 瓦房店市| 怀安县| 正定县| 武胜县| 彭泽县| 海晏县| 无为县| 鹤庆县| 锦州市| 罗田县| 曲麻莱县| 界首市| 登封市| 永登县| 乐东| 梅河口市| 东光县| 新晃| 清原| 五峰| 陆良县| 阿勒泰市| 调兵山市| 镇沅| 永福县| 金川县| 太湖县| 太谷县| 岑巩县| 宜丰县| 岗巴县| 临沭县| 黑水县| 离岛区|