demo@ORA12C> select to_char( min(hiredate) over() ,'yyyymmdd') min_dt,
2 count(*) over() cnt,
3 ename||','||job||','||mgr||','||'etc.' vls
4 from emp ;
MIN_DT CNT VLS
-------- ---------- -------------------------
19801217 14 SMITH,CLERK,7902,etc.
19801217 14 ALLEN,SALESMAN,7698,etc.
19801217 14 WARD,SALESMAN,7698,etc.
19801217 14 JONES,MANAGER,7839,etc.
19801217 14 MARTIN,SALESMAN,7698,etc.
19801217 14 BLAKE,MANAGER,7839,etc.
19801217 14 CLARK,MANAGER,7839,etc.
19801217 14 SCOTT,ANALYST,7566,etc.
19801217 14 KING,PRESIDENT,,etc.
19801217 14 TURNER,SALESMAN,7698,etc.
19801217 14 ADAMS,CLERK,7788,etc.
19801217 14 JAMES,CLERK,7698,etc.
19801217 14 FORD,ANALYST,7566,etc.
19801217 14 MILLER,CLERK,7782,etc.
14 rows selected.
demo@ORA12C> select to_char(null) min_dt, to_number(null) as cnt,
2 'MN' as vls , 1 x
3 from dual union all
4 select to_char( min(hiredate) over() ,'yyyymmdd') min_dt,
5 count(*) over() cnt,
6 ename||','||job||','||mgr||','||'etc.' vls ,2 x
7 from emp union all
8 select to_char(null) min_dt, to_number(null) as cnt,
9 'CT' as vls , 3 x
10 from dual ;
MIN_DT CNT VLS X
-------- ---------- ------------------------- ----------
MN 1
19801217 14 SMITH,CLERK,7902,etc. 2
19801217 14 ALLEN,SALESMAN,7698,etc. 2
19801217 14 WARD,SALESMAN,7698,etc. 2
19801217 14 JONES,MANAGER,7839,etc. 2
19801217 14 MARTIN,SALESMAN,7698,etc. 2
19801217 14 BLAKE,MANAGER,7839,etc. 2
19801217 14 CLARK,MANAGER,7839,etc. 2
19801217 14 SCOTT,ANALYST,7566,etc. 2
19801217 14 KING,PRESIDENT,,etc. 2
19801217 14 TURNER,SALESMAN,7698,etc. 2
19801217 14 ADAMS,CLERK,7788,etc. 2
19801217 14 JAMES,CLERK,7698,etc. 2
19801217 14 FORD,ANALYST,7566,etc. 2
19801217 14 MILLER,CLERK,7782,etc. 2
CT 3
16 rows selected.
demo@ORA12C> select decode(x,1,vls,2,'VLS',3,vls) col,
2 decode(x,1, min(min_dt) over( order by x rows between
3 unbounded preceding and unbounded following ),
4 2,vls,
5 3, min(cnt) over( order by x rows between
6 unbounded preceding and unbounded following) ) val
7 from (
8 select to_char(null) min_dt, to_number(null) as cnt,
9 'MN' as vls , 1 x
10 from dual union all
11 select to_char( min(hiredate) over() ,'yyyymmdd') min_dt,
12 count(*) over() cnt,
13 ename||','||job||','||mgr||','||'etc.' vls ,2 x
14 from emp union all
15 select to_char(null) min_dt, to_number(null) as cnt,
16 'CT' as vls , 3 x
17 from dual ) ;
COL VAL
---------- ------------------------------
MN 19801217
VLS SMITH,CLERK,7902,etc.
VLS ALLEN,SALESMAN,7698,etc.
VLS WARD,SALESMAN,7698,etc.
VLS JONES,MANAGER,7839,etc.
VLS MARTIN,SALESMAN,7698,etc.
VLS BLAKE,MANAGER,7839,etc.
VLS CLARK,MANAGER,7839,etc.
VLS SCOTT,ANALYST,7566,etc.
VLS KING,PRESIDENT,,etc.
VLS TURNER,SALESMAN,7698,etc.
VLS ADAMS,CLERK,7788,etc.
VLS JAMES,CLERK,7698,etc.
VLS FORD,ANALYST,7566,etc.
VLS MILLER,CLERK,7782,etc.
CT 14
16 rows selected.
demo@ORA12C>