2. Write a SELECT statement that returns two columns: VendorName and PaymentSum, where PaymentSum is the sum of the PaymentTotal column. Group the result set by VendorName. Return only 10 rows, corresponding to the 10 vendors who've been paid the most.
Hint: Use the TOP clause and join Vendors to Invoices.
4. Write a SELECT statement that returns three columns: AccountDescription, LineltemCount, and LineltemSum. LineltemCount is the number of entries in the InvoiceLineItems table that have that AccountNo. LineltemSum is the sum of the InvoiceLineItemAmount column for that AccountNo. Filter the result set to include only those rows with LineltemCount greater than l. Group the result set by account description, and sort it by descending LineltemCount.
Hint: Join the GLAccounts table to the InvoiceLineItems table.
6. Write a SELECT statement that answers the following question: What is the total amount invoiced for each AccountNo? Use the WITH ROLLUP operator to include a row that gives the grand total.
Hint: Use the InvoiceLineItemAmount column of the InvoiceLineItems table.
7. Write a SELECT statement that returns four columns: VendorName, AccountDescription, LineltemCount, and LineltemSum. LineltemCount is the row count, and LineltemSum is the sum of the InvoiceLineItemAmount column. For each vendor and account, return the number and sum of line items, sorted first by vendor, then by account description.
Hint: Use a four-table join.
8. Write a SELECT statement that answers this question: Which vendors are being paid from more than one account? Return two columns: the vendor name and the total number of accounts that apply to that vendor's invoices.
Hint: Use the DISTINCT keyword to count InvoiceLineItems.AccountNo.