I assume you're doing something like
select cols, count(*) over ()
from ...
In order to grab that total count at the end of the spool? In terms of efficiency, carrying a total row count throughout the query seems pretty expensive to me
I'd be more inclined just to do something like:
myscript.sql
============
set termout off
set feedback off
set pages 0
set markup csv on
spool c:\tmp\emp.dat
select * from scott.emp;
spool off
host ( awk "END {print NR-2}" c:\tmp\emp.dat >> c:\tmp\emp.dat )