99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2019-02-25 閱讀量: 1228
mysql如何實(shí)現(xiàn)excel的“透視”功能?

問題描述:

透視功能是excel最常用的操作之一,對于取數(shù)需求來說非常常見,如何利用mysql予以實(shí)現(xiàn)呢?


解決思路:

  • 用臨時(shí)表+表鏈接的形式即可實(shí)現(xiàn),例如

create temporary table aa as 
(select CustomerID as '客戶ID',sum(Quantity) as '2017購買數(shù)量' from orderinfo
where year(OrderDate)='2017'
and orderinfo.CustomerID in (select distinct CustomerID from orderinfo where year(OrderDate)='2016')
group by CustomerID);

create temporary table bb as
(select CustomerID as '客戶ID',sum(Quantity) as '2016購買數(shù)量' from orderinfo
where year(OrderDate)='2016'
group by CustomerID) ;

select aa.客戶ID,2016購買數(shù)量,2017購買數(shù)量 from aa,bb where aa.客戶ID=bb.客戶ID;
6.0239
3
關(guān)注作者
收藏
評論(0)

發(fā)表評論

暫無數(shù)據(jù)
推薦帖子