SQL Consider the database table structure shown in the figure. Write a SELECT st
ID: 3730411 • Letter: S
Question
SQL
Consider the database table structure shown in the figure. Write a SELECT statement (oompatible with an Oracie RDBMS) that returns the largest credit total for each vendor over all the invoices that belong to that vendor. The list returned should be in order by credit total, from smallest to largest Table: invoices Column Name Data Type invoice id vendor_id invoice_number varchar2(50) invoice date invoice t number(9,2) payment total number(9,2) credit total terms id invoice due date date payment date date Nullable Default Data Constraint date number(9,2) Yes Table: invoice line items Column Name invoice id invoice sequence NUMBER account_number NUMBER line item amt line item description VARCH100) No Nullable Default Data Constraint Data Type NUMBER PK,FK FK NUMBER(9,2)NoExplanation / Answer
Please find the select query below which returns vendor id along with maximum total credit of the vendor in ascendingorder of the total credit.
SELECT
vendor_id,
MAX(credit_total) AS 'total_credit'
FROM
invoices
GROUP BY
vendor_id
ORDER BY
total_credit
Please let me know if you face any difficulty understanding the solution.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.