Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Can I do this strictly in SQL*Plus?
There are all kinds of ways to do this. Both of the following methods
produce the output that you have requested and only run one select
statement on one table at a time, as you insist upon doing.
SET ECHO OFF FEEDBACK OFF HEADING OFF VERIFY OFF DEFINE total_count = 0
COLUMN running_count NOPRINT NEW_VALUE total_count COLUMN c1_count NOPRINT NEW_VALUE count1 COLUMN c2_count NOPRINT NEW_VALUE count2 SELECT COUNT (*) AS c1_count, &total_count + COUNT (*) AS running_countFROM table1
SELECT COUNT (*) AS c2_count, &total_count + COUNT (*) AS running_countFROM table2
SET SERVEROUTPUT ON
DECLARE
v_count1 INTEGER; v_count2 INTEGER; v_total_count INTEGER;
DBMS_OUTPUT.PUT_LINE ('Total: ' || v_total_count); DBMS_OUTPUT.PUT_LINE ('Count1: ' || v_count1); DBMS_OUTPUT.PUT_LINE ('Count2: ' || v_count2);END;
![]() |
![]() |