Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the database table structure shown in the figure. (a) Write a SELECT st

ID: 3729407 • Letter: C

Question

Consider the database table structure shown in the figure. (a) Write a SELECT statement (compatible with an Oracle RDBMS) that returns all the invoice numbers for invoices with a total greater than 1200 or that are due after June of 2010 and that have an amount due that is positive. (b) Then write two rows of sample data that might be retrieved by the query. What is actually retrieved depends on what is in the table. The data you write does not have to match any data that is actually in our sample tables. Columns Data Constraints Grants Statistics Triggers |Flachback IDependencies Details Partitions Indexes sq NULLABLE ATA DEFAULT COLUMN ID COMMENTS NUMBER NUMBER VARCHAR2(50 BYTE) 3 INVOICE NUMBER INVOICE TOTAL 6 PAYMENT TOTAL 7 CREDIT TOTAL NUMBER(9,2) NUMBER(9,2) NUMBER(9,2) NUMBER 0 PAYMENT DATE

Explanation / Answer

Please find below the SQL Query:-

SELECT INVOICE_ID, SUM(INVOICE_TOTAL) FROM INVOICES GROUP BY INVOICE_ID HAVING SUM(INVOICE_TOTAL) > 1200

UNION

SELECT INVOICE_ID, INVOICE_INVOICE_DUE_DATE FROM INVOICES WHERE INVOICE_DUE_DATE > TO_DATE('01-JUN-2010','DD-MON-YYYY') AND INVOICE_TOTAL > 0;

Please let me know in case of any clarifications required. Thanks!