Write the SQL queries that accomplish the tasks using the AP Database
1. Write a SQL statement to retrieve the InvoiceID, InvoiceDate, InvoiceTotal, BalanceDue, PaymentDate, and AgeofInvoices for the invoices that have more than 30 days of invoice age. Sort the result set by AgeofInvoice in a descending order. (Note: BalanceDue = InvoiceTotal-PaymentTotal-CreditTotal AgeofInvoice is the number of days difference between invoicedate and paymentdate.)
2. For each invoicedate that has more than one invoice, show the invoiceDate and calculate the following values: InvoiceCount, InvoiceSum, InvoiceAvg, InvoiceMin, and InvoiceMax. Sort the result by InvoiceCount, then by InvoiceSum. The definitions of the calculated values are in the following table: InvoiceCount - Number of invoices in each invoicedate. InvoiceSum - Sum of the invoiceTotal of invoices in each invoicedate. InvoiceAvg - Average of the invoiceTotal of invoices in each invoicedate. InvoiceMin - Lowest amount of the InvoiceTotal of invoices in each invoicedate. InvoiceMax - Highest amount of the InvoiceTotal of invoices in each invoicedate
Get Answers For Free
Most questions answered within 1 hours.