Tristan Coopman 8621559762 Bestanden uploaden naar '' | hace 2 años | |
---|---|---|
README.md | hace 2 años | |
exercise1-9.sql | hace 2 años |
Write a SELECT statement that returns one row for each vendor in the Invoices table that contains these columns:
This should return 34 rows.
Write a SELECT statement that returns one row for each vendor that contains these columns:
Sort the result set in descending sequence by the payment total sum for each vendor.
Write a SELECT statement that returns one row for each vendor that contains three columns:
Sort the result set so the vendor with the most invoices appears first.
Write a SELECT statement that returns one row for each general ledger account number that contains three columns:
Return only those rows where the count of line items is greater than 1. This should return 10 rows.
Group the result set by the account_description column.
Sort the result set in descending sequence by the sum of the line item amounts.
Modify the solution to exercise 4 so it returns only invoices dated in the second quarter of 2018 (April 1, 2018 to June 30, 2018).
This should still return 10 rows but with some different line item counts for each vendor.
Hint: Join to the Invoices table to code a search condition based on invoice_date.
Write a SELECT statement that answers this question:
What is the total amount invoiced for each general ledger account number?
Return these columns:
Use the WITH ROLLUP operator to include a row that gives the grand total.
This should return 22 rows.
Write a SELECT statement that answers this question: Which vendors are being paid from more than one account?
Return these columns:
This should return 2 rows.
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:
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.
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:
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.