Challenge

SQL Project - 1. Business model Customer to Customer (C2C) allows customers to do business with each other SQL PROJECT

/* Business model Customer to Customer (C2C) allows customers to do business with each other.
This model is growing fast with e-commerce platforms where sellers may be required to pay some amount and
buyer can buy it without paying anything. E-Commerce website brings the seller and buyer to the same platform.

Analyzing the user's database will lead to understanding the business perspective.
Behaviour of the users can be traced in terms of business with exploration of the user’s database.

Dataset: One .csv file with name users_data with 98913 rows and 27 columns

Tasks to be performed */

-- 1.Q Create new schema as ecommerce
create database ecommerce;
use ecommerce;

-- 2.Q Import .csv file users_data into MySQL
use ecommerce;
select count(*) from users_data;


/* (right click on ecommerce schema
-> Table Data import Wizard
-> Give path of the file
-> Next
-> choose options : Create a new table , select delete if exist -> next -> next) */

-- 3.Q Run SQL command to see the structure of table
desc users_data;

-- 4.Q Run SQL command to select first 100 rows of the database
select * from users_data limit 100;

-- 5.Q How many distinct values exist in table for field country and language
select count(distinct country) country, count(distinct language) language from users_data;

-- 6.Q Check whether male users are having maximum followers or female users.
select gender,sum(socialNBFollowers) from users_data group by gender;

-- 7.Q Calculate the total users those
-- 7.a. Uses Profile Picture in their Profile
select count(hasProfilePicture) Users_with_ProfilePicture from users_data where hasProfilePicture = 'True';

-- 7.b. Uses Application for Ecommerce platform
select count(hasAnyApp) Users_with_Anyapp from users_data where hasAnyApp = 'True';

-- 7.c. Uses Android app
select count(hasAndroidApp) Users_with_Androidapp from users_data where hasAndroidApp = 'True';

-- 7.d. Uses ios app
select count(hasIosApp) Users_with_Iosdapp from users_data where hasIosApp = 'True';

/* 8.Q Calculate the total number of buyers for each country and sort the result in descending order of total number of buyers.
(Hint: consider only those users having at least 1 product bought.) */
select country,count(productsBought) Buyers from users_data group by country order by Buyers desc;

/* 9.Q Calculate the total number of sellers for each country and sort the result in ascending order of total number of sellers.
(Hint: consider only those users having at least 1 product sold.) */
select country,count(productsSold) Sellers from users_data group by country order by Sellers asc;

-- 10.Q Display name of top 10 countries having maximum products pass rate.
select country from users_data group by country having max(productsPassRate) limit 10;

-- 11.Q Calculate the number of users on an ecommerce platform for different language choices.
select language,count(language) from users_data group by language;

/* 12.Q Check the choice of female users about putting the product in a wishlist or to like socially on an ecommerce platform.
(Hint: use UNION to answer this question.) */
select sum(productsWished) ,sum(socialProductsLiked) from users_data where gender='F';
-- choice of ehr female users about putting the product in a wishlist or to like socially om an ecommerce platform is same.

-- 13.Q Check the choice of male users about being seller or buyer. (Hint: use UNION to solve this question.)
select count(productsSold),count(productsBought) from users_data where gender='M';
-- choicr of male users about being seller or buyer is same.

-- 14.Q Which country is having maximum number of buyers?
select country,max(productsBought) Max_no_of_buyers from users_data group by country order by max(productsBought) desc limit 1;
-- Belfique country is having maximum number of buyers.

-- 15.Q List the name of 10 countries having zero number of sellers.
select country , productsSold from users_data where productsSold=0 limit 10;

-- 16.Q Display record of top 110 users who have used ecommerce platform recently.
select * from users_data group by daysSinceLastLogin having min(daysSinceLastLogin) order by daysSinceLastLogin asc limit 110;

-- 17.Q Calculate the number of female users those who have not logged in since last 100 days.
select count(type) from users_data where gender='F' and daysSinceLastLogin >= 100;

-- 18.Q Display the number of female users of each country at ecommerce platform.
select country,count(gender) Female_users from users_data where gender='F' group by country;

-- 19.Q Display the number of male users of each country at ecommerce platform.
select country,count(gender) Male_users from users_data where gender='M' group by country;

-- 20.Q Calculate the average number of products sold and bought on ecommerce platform by male users for each country.
select country,avg(productsSold) Products_sold,avg(productsBought) Products_bought from users_data where gender='M' group by country;

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.