我需要生成如下所示的摘要报告:
我的问题是,
到目前为止,我只知道如何在没有表视图的情况下执行第一行和第一列。
这是我的密码。
SET HEADING OFF;
SET LINESIZE 200;
SET SPACE 0;
SET ECHO OFF;
SET FEEDBACK OFF;
SET VERIFY OFF;
SET MARKUP HTML OFF SPOOL OFF;
SET TERMOUT OFF; --Do not show output to the screen.
SET NEWPAGE NONE; --Remove the first blank line at the top of the page and between queries.
TTITLE LEFT "REPORT NAME" RIGHT "PAGE : " SQL.PNO SKIP 1 -
LEFT "--------------------------------" RIGHT "DATE : " _DATE SKIP 1 -
LEFT "A) TOTAL RECORDS " RIGHT total_records; -- Cannot output variable in the title.
LEFT "B) MATCHED RECORDS " RIGHT matched_records; -- Cannot output variable in the title.
LEFT "C) UNMATCHED RECORDS " RIGHT matched_records; -- Cannot output variable in the title.
BTITLE LEFT "E N D";
total_records是一条插入语句。
SELECT COUNT(*) INTO total_records FROM TABLE;
我还没有完成匹配的记录和不匹配的记录。但我能想到的唯一方法
我认为这不是最有效的方法。但是,如果您有更好的方法,请告诉我。
这样的东西响吗?示例基于Scott的示例架构:
SQL> select 'Total records' name, count(*) cnt
2 from emp
3 union all
4 select 'Matched count', sum(case when deptno = 10 then 1 else 0 end)
5 from emp
6 union all
7 select 'Unmatched count', sum(case when deptno = 10 then 0 else 1 end)
8 from emp;
NAME CNT
--------------- ----------
Total records 14
Matched count 3
Unmatched count 11
SQL>