使用 Oracle 11g
如何编写查询以包含显示返回的总行数的第 4 列?
如here所述,我在发布问题时遇到技术困难 。一旦这篇文章,我将继续我的编辑。
使用窗口函数:
SELECT col1, col2, col3, COUNT(*) OVER () AS total_rows
FROM mytable
如果您的意思是到目前为止的总数,那么:
select c1, c2, c3,
count(*) over (order by c1 range unbounded preceding) as total_rows
from mytable
order by c1
这将得到如下结果:
C1 C2 C3 TOTAL_ROWS
A B C 1
A B D 2
B D E 3
...