Challenge

Project 1

1. Create new schema as ecommerce

create database ecommerce;

2. Import .csv file users_data into MySQL
(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)

use ecommerce;

3. Run SQL command to see the structure of table

desc users_data;

identifierHash bigint YES
type text YES
country text YES
language text YES
socialNbFollowers int YES
socialNbFollows int YES
socialProductsLiked int YES
productsListed int YES
productsSold int YES
productsPassRate double YES
productsWished int YES
productsBought int YES
gender text YES
civilityGenderId int YES
civilityTitle text YES
hasAnyApp text YES
hasAndroidApp text YES
hasIosApp text YES
hasProfilePicture text YES
daysSinceLastLogin int YES
seniority int YES
seniorityAsMonths double YES
seniorityAsYears double YES
countryCode text YES

4. Run SQL command to select first 100 rows of the database

select * from users_data limit 100;

5. How many distinct values exist in table for field country and language

select count(distinct country) as distinct_country, count(distinct language) as distinct_language from users_data;

distinct_country = 200

distinct_language = 5

6. Check whether male users are having maximum followers or female users.

select sum(socialNbFollowers), gender from users_data group by gender;

F 262458
M 77038

7.Calculate the total users those

a. Uses Profile Picture in their Profile

select count(hasProfilePicture) from users_data where hasProfilePicture= "TRUE"; '97018'

b. Uses Application for Ecommerce platform

select count(hasAnyApp) from users_data where hasAnyApp= "TRUE"; '26174'

c. Uses Android app.

select count(hasAndroidApp) from users_data where hasAndroidApp= "TRUE"; '4819'

d. Uses ios app

select count(hasIosApp) from users_data where hasIosApp = "TRUE"; '21527'

8. 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, sum(productsBought) as Total_no_of_buyers from users_data group by country having Total_no_of_buyers >=1
order by Total_no_of_buyers desc;

France 3573
Etats-Unis 2370
Royaume-Uni 2174
Allemagne 1635
Italie 1221
Espagne 1028
Belgique 718
Suède 566
Pays-Bas 537
Danemark 438
Australie 398
Finlande 331
Autriche 242
Luxembourg 162
Roumanie 162
Canada 155
Pologne 150
Suisse 137
Hong Kong 112
Chine 111
Bulgarie 95
Irlande 79
Singapour 75
Portugal 72
Japon 67
Grèce 53
Hongrie 42
Croatie 39
Slovénie 39
Cambodge 39
Macau 19
Ukraine 18
Émirats arabes unis 13
Corée du Sud 11
Norvège 11
Nouvelle Zélande 9
Chypre 9
Taiwan 9
Estonie 9
Israel 8
Russie 8
République tchèque 8
Malaisie 5
Mexique 4
Bahreïn 4
Lituanie 4
Monaco 4
Brésil 4
Turquie 4
Guadeloupe 3
Puerto Rico 3
Géorgie 3
Egypte 3
Indonésie 2
Slovaquie 2
Arabie Saoudite 2
Islande 2
Qatar 1
Colombie 1
Serbie 1
Pakistan 1
Malte 1

9. 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, sum(productsSold) as Total_no_of_sellers from users_data group by country having Total_no_of_sellers >=1
order by Total_no_of_sellers;

ÃŽles Canaries 1
Japon 1
Bahamas 1
Kazakhstan 1
Islande 2
Chine 2
Ukraine 3
Lituanie 4
Estonie 4
Serbie 5
Slovénie 6
Canada 7
Russie 10
Singapour 11
Irlande 16
Finlande 20
Pologne 23
Slovaquie 28
Grèce 31
Portugal 33
Australie 35
Luxembourg 43
Suisse 45
Danemark 50
Hong Kong 50
Chypre 56
Taiwan 57
Autriche 67
Roumanie 68
Lettonie 83
Croatie 107
Belgique 114
Bulgarie 170
Monaco 190
Pays-Bas 214
Suède 336
Allemagne 536
Etats-Unis 967
Espagne 990
Royaume-Uni 1806
Italie 2820
France 3014

10. Display name of top 10 countries having maximum products pass rate.

select country, sum(productsPassRate) as Max_Pass_Rate from users_data group by country order by Max_Pass_Rate desc limit 10;

France 24572.8
Italie 17669
Royaume-Uni 10899.1
Etats-Unis 5865.1
Espagne 5006.6
Allemagne 3821
Pays-Bas 2219.8
Suède 1611.6
Belgique 1304
Autriche 871

-------------------------------------------------- OR --------------------------------------------------

select country from users_data group by country order by sum(productsPassRate) desc limit 10;

France
Italie
Royaume-Uni
Etats-Unis
Espagne
Allemagne
Pays-Bas
Suède
Belgique
Autriche

11. Calculate the number of users on an ecommerce platform for different language choices.

select language, count(type) as no_of_users from users_data group by language;

en 51564
de 7178
fr 26372
es 6033
it 7766

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 'Products wishlisted', sum(productsWished) from users_data where gender = "F"
union
select 'Products liked', sum(socialProductsLiked) from users_data where gender = "F";

Products wishlisted 129498
Products liked 373600

13. Check the choice of male users about being seller or buyer. (Hint: use UNION to solve this question.)

select 'Seller(M)', count(productsListed) from users_data where gender = "M" and productsListed>0
union
select 'Buyer(M)', count(productsBought) from users_data where gender = "M" and productsBought>0 ;

Seller(M) 314
Buyer(M) 1471

14. Which country is having maximum number of buyers?

select country, count(type) as Buyers from users_data where productsBought > 0 group by country limit 1;

France 1251

15. List the name of 10 countries having zero number of sellers.

select country from users_data group by country having sum(productsSold) = 0 limit 10;

Turquie
Réunion
Chili
Djibouti
Congo
Martinique
Sénégal
Maroc
Panama
Équateur

16. Display record of top 110 users who have used ecommerce platform recently.

select * from users_data order by daysSinceLastLogin asc limit 110;

17. 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;

70189

18. Display the number of female users of each country at ecommerce platform.

select country, count(type) from users_data where gender = "F" group by country;

Etats-Unis 17079
Allemagne 4577
Turquie 85
Royaume-Uni 8732
Italie 5984
Espagne 4527
Danemark 1414
France 18085
Suisse 667
Chili 37
Congo 11
Irlande 379
Suède 1257
Martinique 24
Canada 1289
Australie 2203
Belgique 1374
Pays-Bas 1360
Chine 368
Maroc 113
Panama 10
Portugal 166
Équateur 10
Hong Kong 748
Colombie 35
Nouvelle Zélande 90
Pologne 161
Bulgarie 67
Japon 108
Inde 96
Trinidad et Tobago 5
Rwanda 1
Émirats arabes unis 112
Singapour 198
Mexique 136
Corée du Sud 107
Brunei Darussalam 10
Le Salvador 2
République dominicaine 6
Brésil 77
Argentine 26
Algérie 47
Finlande 494
Grèce 197
Qatar 40
Malaisie 93
Tunisie 55
Azerbaïdjan 18
Mali 2
Autriche 536
Russie 426
Niger 1
Hongrie 47
Lettonie 40
Croatie 104
Serbie 48
Malte 21
Roumanie 250
Luxembourg 86
Angola 3
Egypte 25
Indonésie 54
Pakistan 8
Slovaquie 42
Albanie 25
Philippines 85
Puerto Rico 15
Norvège 134
Afrique du Sud 62
Nouvelle Calédonie 13
Iles Cayman 3
Chypre 49
Arabie Saoudite 130
Sri Lanka 1
Guyane 10
Bolivie 3
Cote D'Ivoire 15
Taiwan 99
Pérou 14
Thailande 60
Israel 87
Polynésie Française 7
Ouganda 3
Moldavie 19
Bosnie et Herzegovine 12
Bahreïn 22
Cameroun 12
Kowait 69
Togo 1
Macau 11
Lituanie 36
République tchèque 45
Svalbard et Jan Mayen Islands 1
Arménie 15
Guernsey 1
Myanmar 7
Réunion 40
Slovénie 27
Géorgie 21
Samoa américaines 7
Monaco 31
Ukraine 87
Venezuela 12
Mongolie 10
Guinée 3
Madagascar 8
Guatemala 3
Anguilla 1
Nigeria 21
Kenya 8
Costa Rica 5
Jamaique 2
Viet Nam 46
Cambodge 14
Biélorussie 8
Oman 8
Estonie 28
Liban 33
Îles Turques-et-Caïques 1
Kazakhstan 33
Islande 20
Afghanistan 5
Gabon 7
Érythrée 1
Antigua et Barbuda 2
Jordanie 13
République centrafricaine 1
Benin 3
Bangladesh 5
Iran 12
Zimbabwe 4
Bermude 3
Guadeloupe 25
Guam 1
Syrie 1
Saint Vincent et les Grenadines 1
Gibraltar 1
Géorgie du Sud / Iles Sandwich 1
Ghana 1
Nepal 1
Grenade 2
ÃŽle Bouvet 2
Sénégal 6
Botswana 2
Namibie 2
Laos 2
Maldives 3
Îles Féroé 1
Jersey 8
Cuba 1
Gambie 1
Sainte Lucie 1
Uruguay 3
Andorre 8
Barbade 2
Nicaragua 3
ÃŽles Vierges britanniques 2
Irak 3
Bahamas 2
Tajikistan 2
Macédoine 6
ÃŽles Vierges (U.S.) 2
Djibouti 1
Iles mineures éloignées des États-Unis 1
Tanzanie 2
Fidji 2
Liechtenstein 2
Maurice 3
Corée du Nord 1
ÃŽle Norfolk 1
Kirghizistan 4
Haiti 2
Antilles néerlandaises 1
ÃŽles Malouines 1
Honduras 8
Burkina Faso 2
Palau 1
Paraguay 2
Mauritanie 2
Vanuatu 1
ÃŽles Canaries 2
Aruba 1
Kiribati 3
Suriname 1
Uzbekistan 2
Guyana 1
Samoa 1
Mayotte 1
Saint Kitts et Nevis 1
Dominique 1
Swaziland 1
ÃŽle de Man 1

19. Display the number of male users of each country at ecommerce platform.

select country, count(type) from users_data where gender = "M" group by country;

Suède 569
France 7050
Allemagne 1990
Réunion 11
Danemark 478
Djibouti 5
Italie 2031
Etats-Unis 3523
Royaume-Uni 2578
Espagne 1179
Canada 288
Sénégal 9
Australie 516
Suisse 192
Belgique 292
Singapour 62
Brésil 18
Japon 57
Kowait 8
Martinique 7
Corée du Sud 31
Hong Kong 106
Thailande 18
Mexique 55
Finlande 167
Pakistan 9
Viet Nam 18
Russie 64
Nouvelle Zélande 23
Pays-Bas 169
Mongolie 2
Liban 3
Albanie 12
Guadeloupe 13
Cameroun 8
Roumanie 79
Paraguay 2
Colombie 15
Irlande 73
Malaisie 26
Portugal 46
Inde 61
Nigeria 11
Philippines 13
Chine 60
Maroc 54
Autriche 88
Cote D'Ivoire 15
Afrique du Sud 21
Tunisie 30
Indonésie 21
Taiwan 34
Norvège 44
Tajikistan 2
Cuba 1
Grèce 32
Luxembourg 25
Émirats arabes unis 19
Malte 5
Moldavie 1
Algérie 29
Guinée 2
Îles Turques-et-Caïques 2
Israel 18
Argentine 13
Qatar 7
République tchèque 11
Tanzanie 3
Pérou 12
Turquie 20
Belize 4
Pologne 32
Bulgarie 15
Guyane 4
Géorgie 2
Arabie Saoudite 13
Chili 12
Slovaquie 12
Anguilla 1
Lettonie 8
Ukraine 23
Bolivie 1
Jordanie 4
Chypre 6
Aruba 2
Congo 10
Monaco 5
Syrie 1
Ghana 3
Afghanistan 5
Angola 3
Polynésie Française 1
Azerbaïdjan 4
Éthiopie 1
Bahreïn 3
Macau 5
Panama 2
Kenya 3
Benin 3
Estonie 5
Myanmar 4
Croatie 12
Barbade 1
Ouganda 1
Le Salvador 1
Puerto Rico 4
Lituanie 4
Gabon 4
Liechtenstein 1
Chad 1
Bermude 4
République dominicaine 4
Andorre 1
Hongrie 13
Islande 5
Irak 5
Maurice 2
Togo 2
Équateur 3
Cambodge 9
ÃŽles Vierges britanniques 1
St Barthélémy 1
Bosnie et Herzegovine 2
Antigua et Barbuda 1
Serbie 6
Brunei Darussalam 2
Mali 3
Egypte 3
Bahamas 1
Jersey 2
Bangladesh 4
Kazakhstan 1
Îles Féroé 1
Biélorussie 2
Guam 1
Zaire 1
Macédoine 2
Zambie 1
Dominique 1
Venezuela 2
Costa Rica 3
Zimbabwe 1
Guernsey 2
Gambie 1
Libye 1
Fidji 2
Arménie 1
Madagascar 2
Samoa américaines 2
Slovénie 1
Antarctique 1
Oman 1
Guatemala 1
ÃŽle Bouvet 1
ÃŽles Vierges (U.S.) 1
Uruguay 1
Burkina Faso 1
Laos 1

20. Calculate the average number of products sold and bought on ecommerce platform by male users for each country.

select country, avg(productsSold) as Sold_average, avg(productsBought) as Bought_average from users_data
where gender = "M" group by country;

Suède 0.0615 0.2179
France 0.0921 0.1901
Allemagne 0.0342 0.2196
Réunion 0.0000 0.0000
Danemark 0.0293 0.1444
Djibouti 0.0000 0.0000
Italie 0.4702 0.1709
Etats-Unis 0.0426 0.1425
Royaume-Uni 0.1412 0.2203
Espagne 0.1730 0.1527
Canada 0.0000 0.0972
Sénégal 0.0000 0.0000
Australie 0.0349 0.1492
Suisse 0.0313 0.1458
Belgique 0.0856 0.0890
Singapour 0.0000 0.6774
Brésil 0.0000 0.1111
Japon 0.0000 0.7018
Kowait 0.0000 0.0000
Martinique 0.0000 0.0000
Corée du Sud 0.0000 0.0323
Hong Kong 0.1415 0.2358
Thailande 0.0000 0.0000
Mexique 0.0000 0.0000
Finlande 0.0000 0.2455
Pakistan 0.0000 0.1111
Viet Nam 0.0000 0.0000
Russie 0.0000 0.0156
Nouvelle Zélande 0.0000 0.0000
Pays-Bas 0.4379 0.8225
Mongolie 0.0000 0.0000
Liban 0.0000 0.0000
Albanie 0.0000 0.0000
Guadeloupe 0.0000 0.0769
Cameroun 0.0000 0.0000
Roumanie 0.3038 0.4430
Paraguay 0.0000 0.0000
Colombie 0.0000 0.0000
Irlande 0.0000 0.1507
Malaisie 0.0000 0.0000
Portugal 0.0652 0.4348
Inde 0.0000 0.0000
Nigeria 0.0000 0.0000
Philippines 0.0000 0.0000
Chine 0.0000 0.0667
Maroc 0.0000 0.0000
Autriche 0.0909 0.5795
Cote D'Ivoire 0.0000 0.0000
Afrique du Sud 0.0000 0.0000
Tunisie 0.0000 0.0000
Indonésie 0.0000 0.0476
Taiwan 0.0000 0.1176
Norvège 0.0000 0.0000
Tajikistan 0.0000 0.0000
Cuba 0.0000 0.0000
Grèce 0.0313 0.1250
Luxembourg 0.0400 0.1200
Émirats arabes unis 0.0000 0.0000
Malte 0.0000 0.0000
Moldavie 0.0000 0.0000
Algérie 0.0000 0.0000
Guinée 0.0000 0.0000
Îles Turques-et-Caïques 0.0000 0.0000
Israel 0.0000 0.0000
Argentine 0.0000 0.0000
Qatar 0.0000 0.0000
République tchèque 0.0000 0.1818
Tanzanie 0.0000 0.0000
Pérou 0.0000 0.0000
Turquie 0.0000 0.1500
Belize 0.0000 0.0000
Pologne 0.4688 0.3750
Bulgarie 0.9333 2.8000
Guyane 0.0000 0.0000
Géorgie 0.0000 0.0000
Arabie Saoudite 0.0000 0.0000
Chili 0.0000 0.0000
Slovaquie 2.3333 0.0000
Anguilla 0.0000 0.0000
Lettonie 0.0000 0.0000
Ukraine 0.0000 0.0000
Bolivie 0.0000 0.0000
Jordanie 0.0000 0.0000
Chypre 0.0000 0.0000
Aruba 0.0000 0.0000
Congo 0.0000 0.0000
Monaco 0.0000 0.6000
Syrie 0.0000 0.0000
Ghana 0.0000 0.0000
Afghanistan 0.0000 0.0000
Angola 0.0000 0.0000
Polynésie Française 0.0000 0.0000
Azerbaïdjan 0.0000 0.0000
Éthiopie 0.0000 0.0000
Bahreïn 0.0000 0.0000
Macau 0.0000 0.0000
Panama 0.0000 0.0000
Kenya 0.0000 0.0000
Benin 0.0000 0.0000
Estonie 0.2000 0.6000
Myanmar 0.0000 0.0000
Croatie 0.0000 0.2500
Barbade 0.0000 0.0000
Ouganda 0.0000 0.0000
Le Salvador 0.0000 0.0000
Puerto Rico 0.0000 0.2500
Lituanie 0.0000 0.0000
Gabon 0.0000 0.0000
Liechtenstein 0.0000 0.0000
Chad 0.0000 0.0000
Bermude 0.0000 0.0000
République dominicaine 0.0000 0.0000
Andorre 0.0000 0.0000
Hongrie 0.0000 0.0000
Islande 0.2000 0.2000
Irak 0.0000 0.0000
Maurice 0.0000 0.0000
Togo 0.0000 0.0000
Équateur 0.0000 0.0000
Cambodge 0.0000 4.3333
ÃŽles Vierges britanniques 0.0000 0.0000
St Barthélémy 0.0000 0.0000
Bosnie et Herzegovine 0.0000 0.0000
Antigua et Barbuda 0.0000 0.0000
Serbie 0.0000 0.0000
Brunei Darussalam 0.0000 0.0000
Mali 0.0000 0.0000
Egypte 0.0000 0.3333
Bahamas 0.0000 0.0000
Jersey 0.0000 0.0000
Bangladesh 0.0000 0.0000
Kazakhstan 0.0000 0.0000
Îles Féroé 0.0000 0.0000
Biélorussie 0.0000 0.0000
Guam 0.0000 0.0000
Zaire 0.0000 0.0000
Macédoine 0.0000 0.0000
Zambie 0.0000 0.0000
Dominique 0.0000 0.0000
Venezuela 0.0000 0.0000
Costa Rica 0.0000 0.0000
Zimbabwe 0.0000 0.0000
Guernsey 0.0000 0.0000
Gambie 0.0000 0.0000
Libye 0.0000 0.0000
Fidji 0.0000 0.0000
Arménie 0.0000 0.0000
Madagascar 0.0000 0.0000
Samoa américaines 0.0000 0.0000
Slovénie 0.0000 0.0000
Antarctique 0.0000 0.0000
Oman 0.0000 0.0000
Guatemala 0.0000 0.0000
ÃŽle Bouvet 0.0000 0.0000
ÃŽles Vierges (U.S.) 0.0000 0.0000
Uruguay 0.0000 0.0000
Burkina Faso 0.0000 0.0000
Laos 0.0000 0.0000
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.