Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何在oracle 10g中添加透视表_Sql_Oracle_Oracle10g_Oracle Sqldeveloper - Fatal编程技术网

Sql 如何在oracle 10g中添加透视表

Sql 如何在oracle 10g中添加透视表,sql,oracle,oracle10g,oracle-sqldeveloper,Sql,Oracle,Oracle10g,Oracle Sqldeveloper,如何在oracle 10g中添加PIVOT select date,name,count(ID) from company group by date,name 下面是选择外查询 Date Name Count --------- ------ ----- 22-Dec-16 Create 92 23-Dec-16 Create 61 21-Dec-16 Create 135 26-Dec-16 Insert 2

如何在oracle 10g中添加PIVOT

select date,name,count(ID)
from
company
group by date,name
下面是选择外查询

Date        Name     Count
---------   ------   -----
22-Dec-16   Create      92
23-Dec-16   Create      61
21-Dec-16   Create     135
26-Dec-16   Insert     241
19-Dec-16   Insert       1
26-Dec-16   Delete       1
18-Dec-16   Delete       1
26-Dec-16   Delete     304
25-Dec-16   Delete       1
21-Dec-16   ALTER        2
24-Dec-16   ALTER        3
25-Dec-16   ALTER        8
20-Dec-16   ALTER        1
23-Dec-16   ALTER        1
26-Dec-16   ALTER      791
19-Dec-16   ALTER        1
15-Dec-16   Modify       4
16-Dec-16   Modify      55
17-Dec-16   Modify      47
19-Dec-16   Modify      85
20-Dec-16   Modify     130
22-Dec-16   Modify     270
18-Dec-16   Modify      89
21-Dec-16   Modify     337
26-Dec-16   Modify    1743
23-Dec-16   Modify     373
24-Dec-16   Modify     766
25-Dec-16   Modify    3012
我需要动态地为上面的查询添加透视,将日期添加到列中,将名称添加到行中,然后添加ID的总和

Sum of Count    Column Labels                                               
Row Labels  15-Dec-16   16-Dec-16   17-Dec-16   18-Dec-16   19-Dec-16   20-Dec-16   21-Dec-16   22-Dec-16   23-Dec-16   24-Dec-16   25-Dec-16   26-Dec-16   Grand Total
ALTER                   1   1   2       1   3   8   791 807
Create                          135 92  61              288
Delete              1                           1   305 307
Insert                  1                           241 242
Modify  4   55  47  89  85  130 337 270 373 766 3012    1743    6911
Grand Total 4   55  47  90  87  131 474 362 435 769 3021    3080    8555
当你说“动态”时,可能会重复你的意思是什么?我们可以猜测,但如果只是清楚地解释您的需求,对每个人来说都会更容易。