How to do Pivoting in Oracle 10g

后端 未结 1 1498
耶瑟儿~
耶瑟儿~ 2020-12-04 04:12

Consider the following

Sample Input

SalesBoyName        Product       Amount
------------        -------       ------
Boy1                   


        
相关标签:
1条回答
  • 2020-12-04 04:31

    You can do it like this in 10G:

    select salesboyname, 
           sum (case when product='P1' then amount end) as p1,
           sum (case when product='P2' then amount end) as p2,
           sum (case when product='P3' then amount end) as p3
    from   tblsales
    group by salesboyname;
    

    In 11G there is a PIVOT keyword similar to SQL Server's.

    0 讨论(0)
提交回复
热议问题