Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Basic Customer Order History & Lifetime Value ( SQL Only ) @ P Lang MySC Envil 1 2 3 4 1 2 Fantasy

1. Basic Customer Order History & Lifetime Value (SQL Only)
@ P
Lang
MySC
Envil
1
2
3
4
1
2
Fantasy Cosmetics wants to understand their customers' shopping behavior. Write a query that will return the following 4 values per customer:
customer_name
number_of_invoices: Total number of invoices associated with a customer over all time, regardless of whether the invoice was cancelled or refunded. Return zero if that customer has no invoices.
lifetime_value: This is the sum of how much a customer has spent ("total _price"), totaled across all invoices. Exclude invoices that were cancelled or refunded. Return zero if that customer has no qualifying invoices. All values should be returned as an unsigned integer.
most_recent_invoice_time: The most recent time an invoice was issued for a customer, regardless of whether it was cancelled or refunded. Return NULL if that customer has no invoices.
This query should return results for all customers, even if they do not have any invoices.
Sort the results based on lifetime value from highest-to-lowest, then by customer name in case of ties.
Table definitions and a data sample are given below.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions