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

Please Provide an answer in MYSQL workbench Provide the total dollar amount of i

ID: 3724120 • Letter: P

Question

Please Provide an answer in MYSQL workbench

Provide the total dollar amount of invoices for each customer in the Invoice table that has more than one invoice, return the CustomerId and this totalled amount.

customer table:

Columns:

int(11)

invoice table:  

Columns:

CustomerId int(11) AI PK FirstName varchar(40) LastName varchar(20) Company varchar(80) Address varchar(70) City varchar(40) State varchar(40) Country varchar(40) PostalCode varchar(10) Phone varchar(24) Fax varchar(24) Email varchar(60) SupportRepId

int(11)

Explanation / Answer

select CustomerId, sum(Total)
from invoices
group by CustomerId
having count(*) > 1

This query returns customer id and a total bill of customers who have more than 1 invoice.

**Comment for any further queries.