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 ______________ ;
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 ;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.