Exploratory Data Analysis Using SQL.
Tags: database, analytics, sql, programming
Published: 2022-08-05 21:41:00

***INTRODUCTION***
 
Two years ago when I started learning how to write SQL code and learning how to work with SQL, it felt complex and disjointed to me. But now, working with SQL is one of my favorite thing to do and I totally enjoy analyzing datasets with SQL.

In this project, I carried out an exploratory analysis on petrol/gas prices around the world. The dataset contains records of petrol/gas prices of ALL the countries in the world, daily petrol/gas consumption of each country ,varying prices per liter and barrel as of June, 2022.

Using SQL, I was able to run some queries through the dataset and get answers to some questions and also to get insights.

***DATA PREPARATION AND CLEANING.***

The dataset was first loaded into Microsoft Excel in order to “clean” the dataset, rename the columns, remove outliers and to check for consistency in the dataset.
Here is a picture of the dataset in Microsoft Excel:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j5j4hjwuglk94s39o115.jpeg)

A database was then created in MYSQL, and the dataset was imported into the SQL workbench in order to begin analysis.
Picture of the dataset after being imported into the SQL workbench:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kts78mudvre3zlt0lzuo.jpeg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ext18ng3zifdv3bhya9x.jpeg)


***ANALYSIS***

Analysis was done to get answers to some very important questions and to get an understanding of the dataset.

**PETROL/ GAS CONSUMPTION AROUND THE WORLD.**

1)To start with, I wanted to know the total sum of barrel of petrol/gas consumed by the entire world on a daily basis.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fqun73mslfjvfh89u0d.jpeg)

The query above shows the world consumes 96,576,722 barrels of petrol/ gas on a daily basis, as of June 2022.

2.Country with the highest petrol/gas consumption daily:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t393ojzhse66hyev92dy.jpeg) 

The United States of America consumes the most petrol/gas daily.
19,687,287 barrels per day.

3.Country with the least petrol/ gas consumption daily:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ju7eav6v8gcv5bt2n4ny.jpeg)

 
Niue consumes the least petrol/ gas in the world. 51 barrels per day.
Until while carrying out this analysis, I didn’t know of the country called Niue, had to google it up and realized it’s a country with an average of 1,620 people, located in the Oceania continent. 


4.Top five countries with the highest daily oil consumption:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jv5jb4vkhwoihv1tgi83.png)

 USA, China, India, Japan and Russia  consumes the most petrol/gas daily .


5.Bottom five countries with  the lowest oil consumption around the world:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q7t5tp1l60ogswqioyk2.jpeg)

Niue, Salt Helena, Monsterrat, Kiribati, Saint Pierre & Miquelon consumes the least petrol/ gas around the world.

**PETROL/ GAS PRICE ANALYSIS AROUND THE WORLD:**

1.Country with the highest price for a liter of petrol/gas.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/66ubjk647ejbh4tfpr1m.jpeg)

North Korea sells a liter of petrol/gas for $14.5!
Wow! 

2.Country with the least price for a liter of petrol/gas:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rwqlomm68ttl1sj96shs.jpeg)

Venezuela sells the cheapest petrol/gas in the world, with a liter going for a paltry $0.02 dollar.

3.Country with the highest and lowest price per gallon :

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v67rkgqtidd5s7ll7zu6.jpeg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/peclv5cgc046sd0sugfq.jpeg)

Consistent with the data above, North Korea and Venezuela sells petrol/ gas for the highest and cheapest price per gallon respectively.

4.Top five countries with the most expensive price for a liter of petrol/gas:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2008pgkjbp6ss1i4286g.jpeg)

 North Korea, Tonga, Niue, Honk Kong, and Norway sells  a liter of petrol/gas for the most expensive amount.


5.Bottom five countries with the cheapest price for petrol/ gas:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ovr65lt8h9i6ii0w2nll.jpeg)

Venezuela, Libya, Iran, Brunei and Syria sells a liter of petrol/ gas for the cheapest prices.

            ******

Thanks for reading!

Comments and suggestions, please do send a mail: heyfunmi@gmail.com