Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SQL Please help me by filling in the 5 blanks correctly with SQL commands. Thank

ID: 3591110 • Letter: S

Question

SQL Please help me by filling in the 5 blanks correctly with SQL commands. Thank you!

Fill in the blanks in the SQL statement below that will list the rows with an invoice_total that is greater than or equal to 500 and less than or equal to 1000. Sort in descending sequence by invoice total. Do not return duplicate rows.
       
SELECT _____________*

FROM invoices
WHERE invoice_total BETWEEN 500 AND 1000
ORDER BY invoice_total DESC;

Fill in the blanks in the SQL statement below that will list the invoice number, invoice total and credit which is the total sum of the payment_total and credit_total. Format the payment credit to 2 decimal places.

SELECT invoice_number, invoice_total, _____________ AS credit
FROM invoices;

Fill in the blanks in the SQL statement below that will list the invoice_id, vendor name, invoice_due_date and an extended date of 20 days for all invoices with an invoice_total greater than 3000. Name the new field extended due date.

SELECT invoice_id, name, invoice_due_date, DATE_ADD(invoice_due_date, _______________)
AS extended_due_date
FROM invoices, vendors
WHERE invoices.invoice_id =  vendors.invoice_id
AND invoice_total > 3000 ;

Fill in the blanks in the SQL statement below that will list vendor name, sum of the invoice_total for that vendor. Include a grand total for all vendors at the end.

SELECT vendor_id, name, SUM( ____________ )
FROM vendors, invoices
WHERE vendors_invoice_id = invoices_invoice_id
GROUP BY vendor_id ______________ ;

Accounts Payable Database Listing Description of tables in the AP database Table: general_ledger_accounts general_ledger_accounts(account_number, description) Table: terms terms(terms_id, description, due_days) Table: vendor contacts vendor_contacts(contact_id, last_name, first_name) Table: vendor vendor(vendor_id, name, address1, address2, city, state, zip, phone, contact id, default_terms_id, default_account_number) Table: invoices invoices(vendor_id, number, invoice_date, invoice_total, payment_total, credit_total, terms_id, invoice_due_date, payment_date) Table: invoice_line_items invoice_line_items(invoice_id, sequence, a ccount number, amount, descriptiou

Explanation / Answer

1.

SELECT count(invoice_total)
FROM invoices
WHERE invoice_total BETWEEN 500 AND 1000
ORDER BY invoice_total DESC;

2.

SELECT invoice_number, invoice_total, ROUND(SUM(payment_totalcredit_total), 2) AS credit

FROM invoices;

3.

SELECT invoice_id, name, invoice_due_date, DATE_ADD(invoice_due_date, INTERVAL 20 DAY)
AS extended_due_date
FROM invoices, vendors
WHERE invoices.invoice_id =  vendors.invoice_id
AND invoice_total > 3000 ;

4.

SELECT vendor_id, name, SUM( invoice_total )

FROM vendors, invoices
WHERE vendors_invoice_id = invoices_invoice_id
GROUP BY vendor_id ;