Forum

Posted by chetana, Sept. 29, 2022, 5:10 p.m.

need solution to sql #216

need solution to sql #216: Write a query to return the customer name and the total spend during their first year

Answers

Hi Chetana,

Many of the newer questions don't have solutions immediately - If you post what you have / questions related to it, I'm sure someone will be happy to assist. Looking at it, it seems fairly straightforward at first, but there are several areas to watch out for, including:

- Combining the customers and all their orders

- Finding the date of the first order for each customer, and determining the last possible order date for 1 year later (and note, in a business scenario, this might mean exactly 1 year later or it could mean 365 days, etc)

- Mapping those together to get the totals

- Then completing the final step of the query, determine the actual highest spender

There's of course multiple ways to accomplish each of these depending on your personal style, query preference, etc. Good luck!

SQLPad user avatar

Mike (228)

Sept. 30, 2022, 5:35 a.m.