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

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

成都創(chuàng)新互聯(lián)公司專注于紅崗企業(yè)網(wǎng)站建設(shè),自適應(yīng)網(wǎng)站建設(shè),電子商務(wù)商城網(wǎng)站建設(shè)。紅崗網(wǎng)站建設(shè)公司,為紅崗等地區(qū)提供建站服務(wù)。全流程按需開(kāi)發(fā),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)


查詢的SQL如下
<ol start="1" class="dp-sql" white-space:normal;">

  • 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)容審核.個(gè)人資料' cn union all   

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

  •         select 'photo_album',1,'內(nèi)容審核.相冊(cè)信息' 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)容審核.音樂(lè)專輯' 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)容審核.個(gè)人資料' cn union all   

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

  •         select 'photo_album',1,'內(nèi)容審核.相冊(cè)信息' 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)容審核.音樂(lè)專輯' 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 ;  


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


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


  • Excel中怎么實(shí)現(xiàn)動(dòng)態(tài)行轉(zhuǎn)列
  • 其中type可能是發(fā)布或者審核.


  • ts 表示月 日 和小時(shí)


  • cn表示模塊類(lèi)型


  • val表示數(shù)量.



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


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


  • Excel中怎么實(shí)現(xiàn)動(dòng)態(tài)行轉(zhuǎn)列

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


  • cn和type作為行標(biāo)簽.


  • val作為顯示數(shù)值


  • Excel中怎么實(shí)現(xiàn)動(dòng)態(tài)行轉(zhuǎn)列

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



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


  • Excel中怎么實(shí)現(xiàn)動(dòng)態(tài)行轉(zhuǎn)列

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

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

標(biāo)題名稱:Excel中怎么實(shí)現(xiàn)動(dòng)態(tài)行轉(zhuǎn)列
文章源于:http://bm7419.com/article20/igoojo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、Google用戶體驗(yàn)、做網(wǎng)站、云服務(wù)器、品牌網(wǎng)站設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作