Question: Write a query that will return a list of all customers and their invoices. Return only rows where invoices were created by a user who
Write a query that will return a list of all customers and their invoices. Return only rows where invoices were created by a user who never contacted that particular customer.
For each row, return the invoice number, customer name and the number of contacts that started prior to the time the invoice was created. Order the result by invoice number ascending.
Table definitions and a data sample are given below.
Table: customer
column name column type keyNULL
customername varchar
cityid int
customeraddress varchar
contactperson varchar N
email varchar
phone varchar
Table: invoice
column name column type keyNULL
id int PK
invoicenumber varchar
customerid int FK
useraccountid int
totalprice decimal
timeissued varchar N
timedue varchar N
timepaid varchar N
timecanceled varchar N
timerefunded varchar N
invoice.customerid references customer.id
Table: useraccount
column name column type keyNULL
id int PK
firstname varchar
lastname varchar
username varchar
password varchar
email varchar
phone varchar N
Table: contact
column name column type keyNULL
id int PK
useraccountid int FK
customerid int FK
contacttypeid int
contactoutcomeid int N
additionalcomment varchar N
contactstarttime varchar
contactendtime varchar N
contact.useraccountid references useraccount.id
contact.customerd references customer.id
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
