Could u write code for me please thank you very much 1.Write a SELECT statement
ID: 3530876 • Letter: C
Question
Could u write code for me please thank you very much 1.Write a SELECT statement that returns one row for each vendor that contains these columns from the Invoices table: The vendor_id column The sum of the invoice_total column The result set should be sorted by vendor_id. 2.Write a SELECT statement that returns one row for each vendor that contains these columns: The vendor_name column from the Vendors table The sum of the payment_total column in the Invoices table. The result set should be sorted in descending sequence by the payment total sum for each vendor. 3.Write a SELECT statement that returns one row for each vendor that contains three columns: The vendor_name column from the Vendors table The count of the invoices for each vendor in the Invoices table The sum of the invoice_total column for each vendor in the Invoices table Sort the result set so the vendor with the most invoices appears first. 4.Write a SELECT statement that returns one row for each general ledger acQcount number that contains three columns: The account_description column from the General_Ledger_Accounts table The count of the entries in the Invoice_Line_Items table that have the same account_number The sum of the line item amounts in the Invoice_Line_Items table that have the same account-number Filter the result set to include only those rows with a count greater than 1; group the result set by account description; and sort the result set in descending sequence by the sum of the line item amounts. 5.Modify the solution to exercise 4 to filter for invoices dated in the second quarter of 2008 (April 1, 2008 to June 30, 2008). Hint: Join to the Invoices table to code a search condition based on invoice_date. 6.Write a SELECT statement that answers this question: What is the total amount invoiced for each general ledger account number? Use the ROLLUP operator to include a row that gives the grand total. Hint: Use the line_item_amt column of the Invoice_Line_Items table. 7.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 vendorExplanation / Answer
SELECT Vendorname, InvoiceNumber, InvoiceDate, Invoicetotal FROM Vendors join Invoices ON Vendors.VendorID = Invoices.VendorID GROUP BY Vendorname, InvoiceNumber, InvoiceDate, Invoicetotal HAVING COUNT(InvoiceNumber)=1 ORDER BY Vendorname
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.