Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started