Bart De Lepeleer 2 years ago
parent
commit
3e83930412
1 changed files with 0 additions and 20 deletions
  1. 0
    20
      README.md

+ 0
- 20
README.md View File

@@ -73,24 +73,4 @@ Return these columns:

This should return 2 rows.

### Exercise 8

Write a SELECT statement that answers this question: What are the last payment date and total amount due for each vendor with each terms id? Return these columns:

- The terms_id column from the Invoices table The vendor_id column from the Invoices table
- The last payment date for each combination of terms id and vendor id in the Invoices table - The sum of the balance due (invoice_total - payment_total - credit_total) for each combination of terms id and vendor id in the Invoices table

Use the WITH ROLLUP operator to include rows that give a summary for each terms id as well as a row that gives the grand total. This should return 40 rows.

Use the IF and GROUPING functions to replace the null values in the terms_id and vendor_id columns with literal values if they’re for summary rows.

### Exercise 9

Write a SELECT statement that uses aggregate window functions to calculate the total due for all vendors and the total due for each vendor.

Return these columns:

- The vendor id from the Invoices table The balance due (invoice_total - payment_total - credit_total) for each invoice in the Invoices table with a balance due greater than 0
- The total balance due for all vendors in the Invoices table The total balance due for each vendor in the Invoices table

Modify the column that contains the balance due for each vendor so it contains a cumulative total by balance due. This should return 11 rows.

Loading…
Cancel
Save