Question
Using the same principle as last week's project update your report to produce a report grouped by date, ordered by last name with a subtotal
Using the same principle as last week's project update your report to produce a report grouped by date, ordered by last name with a subtotal for either the number of people per day or the rate, or both.
How can I show either the number of people per day or the rate or both please help me please
SQL> SET SERVEROUT ON FORMAT TRUNCATED SQL> DECLARE 2 Room_rec DDI.LEDGER_VIEW%ROWTYPE; 3 Last_room DDI.LEDGER_VIEW.ROOMNUM%TYPE := 0; 4 Sub_Total number := 0; 5 Grand_Total number := 0; 6 7 PROCEDURE HEAD_OF_FORM 8 IS 9 BEGIN 10 DBMS_OUTPUT.NEW_LINE; 11 DBMS_OUTPUT.PUT_LINE(' Room Rates from DDI.LEDGER_VIEW by Room Number '); 12 DBMS_OUTPUT.PUT_LINE('ID RegDate Last First Adults Children Size Beds Rate'); 13 DBMS_OUTPUT.PUT_LINE('--- --------- ------------ ------------ -------- ----------- ----- ------ -----'); 14 END; 15 16 PROCEDURE FORM_BREAK(v_subtot IN OUT NUMBER) 17 IS 18 BEGIN 19 DBMS_OUTPUT.PUT_LINE(' --------'); 20 DBMS_OUTPUT.PUT_LINE('Subtotal ' || 21 LPAD(TO_CHAR(Sub_Total, '$99,999'),8)); 22 DBMS_OUTPUT.NEW_LINE; 23 v_subtot := 0; 24 END; 25 26 PROCEDURE END_OF_FORM (v_gtot IN NUMBER) 27 IS 28 BEGIN 29 DBMS_OUTPUT.PUT_LINE(' --------'); 30 DBMS_OUTPUT.PUT_LINE('Grand Total ' || 31 LPAD(TO_CHAR(v_gtot, '$99,999'),8)); 32 END; 33 34 BEGIN 35 FOR Room_rec IN 36 (SELECT * 37 FROM DDI.LEDGER_VIEW 38 ORDER BY ROOMNUM, REGDATE) 39 LOOP 40 IF (Last_room = 0) THEN 41 HEAD_OF_FORM; 42 DBMS_OUTPUT.PUT(LPAD(TO_CHAR(Room_rec.ROOMNUM,'999'), 4)); 43 Last_room := Room_rec.ROOMNUM; 44 Sub_Total := Sub_Total + Room_rec.ROOMRATE; 45 Grand_Total := Grand_Total + Room_rec.ROOMRATE; 46 ELSIF (Room_rec.Roomnum <> Last_room) THEN 47 FORM_BREAK(Sub_Total); 48 HEAD_OF_FORM; 49 DBMS_OUTPUT.PUT(LPAD(TO_CHAR(Room_rec.ROOMNUM,'999'), 4)); 50 Last_room := Room_rec.ROOMNUM; 51 Sub_Total := Sub_Total + Room_rec.ROOMRATE; 52 Grand_Total := Grand_Total + Room_rec.ROOMRATE; 53 ELSE 54 DBMS_OUTPUT.PUT(' '); 55 Sub_Total := Sub_Total + Room_rec.ROOMRATE; 56 Grand_Total := Grand_Total + Room_rec.ROOMRATE; 57 END IF; 58 DBMS_OUTPUT.PUT(' '); 59 DBMS_OUTPUT.PUT(LPAD(TO_CHAR(Room_rec.ROOMNUM, '999'), 4)); 60 DBMS_OUTPUT.PUT(' '); 61 DBMS_OUTPUT.PUT(LPAD(TO_CHAR(Room_rec.REGID, '999'), 4)); 62 63 DBMS_OUTPUT.PUT(' '); 64 DBMS_OUTPUT.PUT(TO_CHAR(Room_rec.REGDATE, 'MM/DD/YY')); 65 DBMS_OUTPUT.PUT(' '); 66 DBMS_OUTPUT.PUT(RPAD(Room_rec.LASTNAME,12)); 67 DBMS_OUTPUT.PUT(' '); 68 DBMS_OUTPUT.PUT(RPAD(Room_rec.FIRSTNAME,12)); 69 DBMS_OUTPUT.PUT(' '); 70 DBMS_OUTPUT.PUT(LPAD(TO_CHAR(Room_rec.ADULTCNT, '99'), 4)); 71 DBMS_OUTPUT.PUT(' '); 72 DBMS_OUTPUT.PUT(LPAD(TO_CHAR(Room_rec.CHILDCNT, '99'), 4)); 73 DBMS_OUTPUT.PUT(' '); 74 DBMS_OUTPUT.PUT(RPAD(Room_rec.ROOMSIZE,8)); 75 DBMS_OUTPUT.PUT(' '); 76 DBMS_OUTPUT.PUT(LPAD(TO_CHAR(Room_rec.ROOMBEDCNT, '99'), 4)); 77 DBMS_OUTPUT.PUT(' '); 78 DBMS_OUTPUT.PUT(LPAD(TO_CHAR(Room_rec.ROOMRATE, '$9,999'),6)); 79 DBMS_OUTPUT.NEW_LINE; 80 END LOOP; 81 FORM_BREAK(Sub_Total); 82 END_OF_FORM(Grand_Total); 83 EXCEPTION 84 WHEN NO_DATA_FOUND THEN 85 DBMS_OUTPUT.PUT_LINE('No data found.'); 86 87 END; 88 /
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started