I've started learning SQL*Plus using one of those 1 day class books and would like to know how I might enhance this report. The example in the book didn't show for multiple conditions, so perhaps I have to write the query another way? I would like to insert a break between the F and T and be able to put in different description for those subtotals such as 'Total F' and 'Total T'. Also how would I remove the second overall total. I have changed the numbers since this is taken from actual data.
[tt]
Term L Co APPLIED ACCEPTED NETACCEPTED DENIED CANCELLED WITHDRAWN DEPOSITED
------ - -- ---------- ---------- ----------- ---------- ---------- ---------- ----------
200740 F LA 1111 1111 1111 1111 1111 0 1111
200740 F SC 2222 222 222 222 222 0 22
200740 F BN 3333 333 333 333 333 0 33
200740 F NS 444 444 444 444 444 0 44
200740 F 5555 5555 5555 5555 5555 0 555
200740 T LA 1111 1111 1111 1111 1111 0 1111
200740 T SC 2222 222 222 222 222 0 22
200740 T BN 3333 333 333 333 333 0 33
200740 T NS 444 444 444 444 444 0 44
200740 T 5555 5555 5555 5555 5555 0 555
200740 5555 5555 5555 5555 5555 0 555[/tt]
So that it looks more like this:
[tt]
Term L Co APPLIED ACCEPTED NETACCEPTED DENIED CANCELLED WITHDRAWN DEPOSITED
------ - -- ---------- ---------- ----------- ---------- ---------- ---------- ----------
200740 F LA 1111 1111 1111 1111 1111 0 1111
200740 F SC 2222 222 222 222 222 0 22
200740 F BN 3333 333 333 333 333 0 33
200740 F NS 444 444 444 444 444 0 44
200740 Total F 5555 5555 5555 5555 5555 0 555
200740 T LA 1111 1111 1111 1111 1111 0 1111
200740 T SC 2222 222 222 222 222 0 22
200740 T BN 3333 333 333 333 333 0 33
200740 T NS 444 444 444 444 444 0 44
200740 Total T 5555 5555 5555 5555 5555 0 555
200740 Total 6666 6666 6666 6666 6666 0 666
[/tt]
This is what I currently have:
The second part of the question is whether this can be cross tabbed so that College goes across and APPLIED, ACCEPTED, etc go down something like this:
[tt]
Term L STATUS LA SC BN NS SC TOTAL
------ - ------------ ---- ---- ----- ------ ----- -----
200740 F APPLIED
200740 F ACCEPTED
200740 F NET ACCEPTED
...
...
Total F
...
...
Total T
...
...
Total[/tt]
[tt]
Term L Co APPLIED ACCEPTED NETACCEPTED DENIED CANCELLED WITHDRAWN DEPOSITED
------ - -- ---------- ---------- ----------- ---------- ---------- ---------- ----------
200740 F LA 1111 1111 1111 1111 1111 0 1111
200740 F SC 2222 222 222 222 222 0 22
200740 F BN 3333 333 333 333 333 0 33
200740 F NS 444 444 444 444 444 0 44
200740 F 5555 5555 5555 5555 5555 0 555
200740 T LA 1111 1111 1111 1111 1111 0 1111
200740 T SC 2222 222 222 222 222 0 22
200740 T BN 3333 333 333 333 333 0 33
200740 T NS 444 444 444 444 444 0 44
200740 T 5555 5555 5555 5555 5555 0 555
200740 5555 5555 5555 5555 5555 0 555[/tt]
So that it looks more like this:
[tt]
Term L Co APPLIED ACCEPTED NETACCEPTED DENIED CANCELLED WITHDRAWN DEPOSITED
------ - -- ---------- ---------- ----------- ---------- ---------- ---------- ----------
200740 F LA 1111 1111 1111 1111 1111 0 1111
200740 F SC 2222 222 222 222 222 0 22
200740 F BN 3333 333 333 333 333 0 33
200740 F NS 444 444 444 444 444 0 44
200740 Total F 5555 5555 5555 5555 5555 0 555
200740 T LA 1111 1111 1111 1111 1111 0 1111
200740 T SC 2222 222 222 222 222 0 22
200740 T BN 3333 333 333 333 333 0 33
200740 T NS 444 444 444 444 444 0 44
200740 Total T 5555 5555 5555 5555 5555 0 555
200740 Total 6666 6666 6666 6666 6666 0 666
[/tt]
This is what I currently have:
Code:
SQL> SET PAGESIZE 66
SQL> SET LINESIZE 100
SQL> COLUMN ACADEMIC_PERIOD HEADING "Term" FORMAT A6
SQL> COLUMN Student_Population HEADING "Level" FORMAT A1
SQL> COLUMN College HEADING "College" FORMAT A2
SQL> SELECT ACADEMIC_PERIOD, Student_Population,
2 College, COUNT(ID) Applied,
3 SUM(CASE WHEN LATEST_DECISION IN ('CC', 'CD', 'CP', 'CX', 'DC', 'HN', 'N6', 'N7', 'N8', 'PB', '
PH', 'PT', 'QA', 'TL', 'TO', 'US', 'WA', 'WC', 'WT') THEN 1 ELSE 0 END) Accepted,
4 SUM(CASE WHEN LATEST_DECISION = 'CC' OR (inst_admit_any_time_ind = 'Y' and LATEST_DECISION <> '
CD') THEN 1 ELSE 0 END) NetAccepted,
5 SUM(CASE WHEN LATEST_DECISION = 'RJ' THEN 1 ELSE 0 END) Denied,
6 SUM(CASE WHEN LATEST_DECISION IN ('CA','CX') THEN 1 ELSE 0 END) Cancelled,
7 SUM(CASE WHEN LATEST_DECISION IN ('WA') THEN 1 ELSE 0 END) Withdrawn,
8 SUM(CASE WHEN LATEST_DECISION IN ('PB','PH','PT','WA') THEN 1 ELSE 0 END) Deposited,
9 SUM(CASE WHEN LATEST_DECISION IN ('PB','PH','PT','WA') THEN 1 ELSE 0 END) ITE
10 FROM ODSMGR.ADMISSIONS_APPLICATION
11 WHERE ( SUBSTR(PROGRAM,1,2) <> 'ND' ) AND ( PROGRAM IS NOT NULL )
12 AND ( STUDENT_LEVEL IN ('UG') )
13 AND ( ACADEMIC_PERIOD IN ('200740') )
14 AND ( STUDENT_POPULATION <> 'S')
15 GROUP BY ROLLUP(ACADEMIC_PERIOD, Student_Population, College)
16 ORDER BY 1,2,DECODE (COLLEGE,'LA', 1, 'SC', 2, 'BN', 3, 'NS', 4, 'PS', 5);
The second part of the question is whether this can be cross tabbed so that College goes across and APPLIED, ACCEPTED, etc go down something like this:
[tt]
Term L STATUS LA SC BN NS SC TOTAL
------ - ------------ ---- ---- ----- ------ ----- -----
200740 F APPLIED
200740 F ACCEPTED
200740 F NET ACCEPTED
...
...
Total F
...
...
Total T
...
...
Total[/tt]