如何编写SQL查询
A 1
B 1
C 1
A 1
A 1
B 1
B 1
C 1
B 1
使其看起来像
A 3
B 4
C 2
A 3
A 3
B 4
B 4
C 2
B 4
答案 0 :(得分:2)
SELECT field1, SUM(field2) OVER (PARTITION BY field1) as total
FROM table1
有关Oracle中窗口/分析函数的更多信息:http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions004.htm