Customer-Segmentation

The provided SQL code offers several queries to analyze a retail dataset. The dataset includes information on invoices, customers, products, and prices.

The queries provided include:

Inspecting the data with a SELECT statement Checking the data values with various SELECT DISTINCT and COUNT statements Finding the highest price per stock code for each customer using the RANK function Ranking stock codes per number of purchases using the DENSE_RANK function Ranking customers according to their total number of trades using the DENSE_RANK function Selecting the top three customers based on the amount paid for orders Querying the last and first purchasing dates for each customer using the FIRST_VALUE and LAST_VALUE functions Using the NTILE function to create RFM scores (recency, frequency, monetary) for each customer Assigning customer segments based on the RFM scores using a CASE statement These queries are intended to help understand the retail dataset and segment customers based on their purchase behavior.

You can read the code commentts to provide clear explanations of each query and its purpose.

To use this code, you will need to have access to a SQL database containing a retail dataset. You can copy and paste the queries into your SQL editor or run them directly from a SQL script file.

Please note that the queries provided are examples and may need to be modified to fit your specific dataset and analysis goals.