Analysis of Sales Data Using SQL

Analysis of Sales Data Using SQL

Dear Hashnoders! It is with joy I present to you, my very first SQL project💃. After learning to some extent on DataCamp, I decided it was time to download SQL on my laptop and begin working on a few projects.

Today, I analyzed sales data on a pre-existing database created by Kevin Cookie Company (KCC). The dataset's owner is Kevin Stratvert, one of my favourite YouTubers. I recommend you check out his channel here.

Tool used for the Analysis: Microsoft SQL Server

Step 1: Analytical Questions

Before beginning the analysis, I asked myself a couple of questions. These questions served as the goal of my analysis. They were:

  • Which type of dataset am I dealing with?

Anwer: Sales Data

  • Can you identify the primary and foreign keys in each table?

Answer: Yes, SQL had already identified the primary keys in each table

  • Who are the customers?

  • Who is the top customer?

  • How is the company doing financially?

Step 2: Queries

A database query is a request for data from a database. It other terms, you are asking for data from SQL.

First: The Select query

I believe it's a subtle tradition for most 'first' queries to be the SELECT query. I used this query to help me identify the customers of the company. Noticing the number of customers, it is safe to assume the company operates on a wholesale basis or a manufacturer basis. 2022-10-04 (7).png

Notice that there is a customer's name that is repeated. I understood that in a real life scenario, duplicates can do a lot of harm when carrying out analysis. I used the SELECT DISTINCT query to rectify this problem.

2022-10-04 (5).png

Who then is the customer the top customer you may be wondering...

Well I was wondering also and for a moment. I didn't know how to go about identifying the top customer. Then I remembered joins from the DataCamp classes. I noticed that one of the four tables contained in the database was for Orders. At that moment, I felt like I had a superpower.

I cracked my knuckles, cracked my neck, looked at my screen and told the table, you are about to be joined 😎

Then I joined the Orders table to the Customers table using the INNER JOIN query and I took a step further by requesting the query to also give me the address of the customers.

After, I exported the result to Microsoft Excel, inserted a Pivot Column and sorted the customer name by the sum of the purchases.

Now then, our customer of the year is.. drumroll...

Park & Shop Convenience Stores!!

2022-10-04 (12).png

Moving on, I noticed that there was a column under the Customers table called Notes. The database was used by Kevin to explain the Intro to SQL, a tutorial video. I watched it for a few minutes and luckily he explained what the Notes column was for. It was a summarized description of each customer.

Then I decided to relate it to the customers and their level of purchase. I have to be honest, there is this sense of joy that comes with working with data. Just knowing there is soo much you can do with it is oddly satisfying.

I got curious and added Notes to the select query. That's when I saw it. Park & Shop Convenience Stores happened to be a new customer. They most likely had decided to make the Kevin Cookie Companies their only supplier for cookies.

2022-10-04 (9).png

Lastly..

I adjusted the column headings to have spaces in between and removed the DISTINCT query as it was not necessary anymore.

2022-10-04 (11).png

Step 3: Insights

My first insight is Park & Shop Convenience Stores deserves a bucket of KFC chicken for haven patronised Kevin Cookie Companies the most😌

okay my actual insights were:

1) Park & Shop Convenience Stores is the top customer for the period considered.

2) Based on the Notes column, ACME Bites can be seen as a loyal customer.

3) They made a profit of approximately 14 dollars per cookie. I got this by subtracting the cost of each cookie from the revenue from each cookie.

4) Although there was no table describing other expenses that may have occurred, based on what I could see, the company is doing very good financially. Not only are they making twice of what they spent on cookies, but the consistency in purchases over the given period also shows that there is a high rate of turnover.

5) Kevin Cookies Company makes good cookies. I mean, what else would keep their customers coming back😉

Extras

Get started with SQl today💃

To download SQL Server Management Studio: %[learn.microsoft.com/en-us/sql/ssms/download..

To download SQL Server: %[microsoft.com/en-us/sql-server/sql-server-d..

Looking for where to learn for free? Check here

Feel free to connect with me on LinkedIn

Alright then, till next time!

Â