- Created a new schema named "ecommerce."
- Imported a .csv file named "users_data" into MySQL.
use ecommerce;
- Checked the structure of the "users_data" table.
desc users_data;
- Displayed the first 100 rows of the "users_data" table.
select * from users_data limit 100;
- Counted the distinct values for the "country" and "language" fields in the table.
select count(distinct(country)) Countries, count(distinct(language)) languages from users_data;
- Checked whether male or female users have the maximum number of followers.
select gender, sum(socialNbFollowers) from users_data group by gender;
- Investigated various aspects of user behavior, including the use of profile pictures and mobile apps.
-- 7.(a) Total users who Use Profile Picture in their Profile
select sum(hasProfilePicture = "True" ) from users_data;
-- 7.(b) Total users who Use Application for E-commerce platform
select sum(hasAnyApp = "True") from users_data;
-- 7.(c) Total users who Use Android app
select sum(hasAndroidApp = "True") from users_data;
-- 7.(d) Total users who Use iOS app
select sum(hasIosApp = "True") from users_data;
- Calculated the total number of buyers and sellers for each country and sorted the results.
-- 8. Calculate the total number of buyers for each country and
-- sort the result in descending order of total number of buyers.
-- (Consider only those users having at least 1 product bought.)
SELECT
COUNT(*) Buyers , country
FROM
users_data
WHERE
productsBought >=1
GROUP BY country
ORDER BY Buyers DESC ;
- Displayed the names of the top 10 countries with the highest products pass rate.
select country , productsPassRate from users_data order by productsPassRate desc limit 10;
- Counted the number of users for different language choices.
select language, count(*) number_of_users from users_data GROUP BY language;
- Explored female user preferences regarding wishlisting products and liking socially on the e-commerce platform using UNION.
-- 12. 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) as wishlist_products_to_total_liked, gender from users_data where gender = "F"
union
select sum(socialProductsLiked), gender from users_data where gender = "F";
- Analyzed male user preferences regarding being sellers or buyers using UNION.
-- 13. Check the choice of male users about being seller or buyer. (Hint: use UNION
-- to solve this question.)
select count(gender) Sellers_to_buyers , gender from users_data where gender = "M" and productsSold >= 1
Union
select count(gender) , gender from users_data where gender = "M" and productsBought >= 1;
- Determined the country with the maximum number of buyers.
-- 14. Which country is having the maximum number of buyers?
SELECT
country ,COUNT(*) Buyers
FROM
users_data
WHERE
productsBought >= 1
GROUP BY country
ORDER BY Buyers DESC limit 1;
- Listed the names of 10 countries with zero sellers.
-- 15. List the name of 10 countries having zero number of sellers.
SELECT
country ,productsSold
FROM
users_data
where productsSold = 0
GROUP BY country limit 10;
- Displayed records of the top 110 users who have recently used the e-commerce platform.
-- 16. Display record of top 110 users who have used ecommerce
-- platform recently.
SELECT
*
FROM
users_data
ORDER BY daysSinceLastLogin
LIMIT 110;
- Calculated the number of female users who have not logged in for over 100 days.
-- 17. Calculate the number of female users those who have not
-- logged in since last 100 days.
SELECT
count(*)
FROM
users_data
WHERE
daysSinceLastLogin > 100
AND gender = 'F'; -- 70189
- Displayed the number of female users in each country on the e-commerce platform.
-- 18. Display the number of female users of each country at ecommerce platform.
SELECT
country, COUNT(*) Female_users
FROM
users_data
where gender = 'F'
GROUP BY country
ORDER BY COUNT(country) DESC;
- Displayed the number of male users in each country on the e-commerce platform.
-- 19. Display the number of male users of each country at ecommerce platform.
SELECT
country, COUNT(country) Male_users
FROM
users_data
where gender = "M"
GROUP BY country
ORDER BY COUNT(country) DESC;
- Calculated the average number of products sold and bought on the e-commerce platform by male users for each country.
-- 20. Calculate the average number of products sold and bought
-- on ecommerce platform by male users for each country
SELECT
country,
AVG(productsSold) AvgProductsSoldbyMale,
AVG(productsBought) AvgProductsBoughtbyMale
FROM
users_data
WHERE
gender = 'M'
GROUP BY country
ORDER BY AVG(productsSold) desc, AVG(productsBought);
This README file provides an overview of the tasks performed on the E-Commerce dataset using SQL. Each task is accompanied by the corresponding SQL command and a brief explanation of the insights obtained. The tasks range from data