Please Provide an answer in MYSQL workbench Write a SELECT statement that totals
ID: 3723022 • Letter: P
Question
Please Provide an answer in MYSQL workbench
Write a SELECT statement that totals all the invoice amounts by SupportRepId. Return the supportrepid and the total. Sort the results so that the support rep id with the largest total of invoices is at the top.
invoice table:
columns:
Customer table:
culomns:
InvoiceId int(11) AI PK CustomerId int(11) InvoiceDate datetime BillingAddress varchar(70) BillingCity varchar(40) BillingState varchar(40) BillingCountry varchar(40) BillingPostalCode varchar(10) Total decimal(10,2)Explanation / Answer
Following is the MySql Query that totals all the invoice amounts by SupportRepId. Returns the supported and the total and Sort the results so that the support rep id with the largest total of invoices is at the top.
select sum(i.Total),c.SupportRepId from[Invoice] i join Customer c on i.CustomerId = c.CustomerId Group By c.SupportRepId Order By sum(i.Total) Desc
Desc = Descending Order