Search code examples
sqloraclecountoracle11ganalytics

How do I get total count of result set to appear in every record of output?


Using Oracle 11g

How can I write query to include a 4th column which displays the total rows returned?

I'm having technical difficulties posting a question as noted here. As soon as this posts, I'll continue with my edit.


Solution

  • Use the window function:

    SELECT  col1, col2, col3, COUNT(*) OVER () AS total_rows
    FROM    mytable