Project 1
-- 1ST
CREATE DATABASE ecommerce;
-- 3rd
USE ecommerce;
SELECT * FROM users_data;
-- 4th
SELECT * FROM users_data LIMIT 100 ;
-- 5th
SELECT DISTINCT( language) from users_data ;
SELECT DISTINCT (country ) from users_data ;
-- 6th
SELECT SUM(socialNbFollowers) ,gender from users_data GROUP BY gender;
-- 7th
SELECT COUNT(hasAndroidAPP)FROM users_data WHERE hasAndroidAPP='True';
SELECT COUNT(hasAnyApp)FROM users_data WHERE hasAnyAPP='True';
SELECT COUNT(hasIosApp) FROM users_data WHERE hasIosApp='True' ;
SELECT COUNT(hasProfilePicture) FROM users_data WHERE hasProfilePicture='True' ;
-- 8TH
SELECT distinct(country) , sum(productsBought) SUM from users_data WHERE productsBought >= 1 GROUP BY country ORDER BY SUM DESC ;
-- 9TH
SELECT distinct(country) , sum(productsSold) SUM from users_data WHERE productsSold >= 1 GROUP BY country ORDER BY SUM ASC ;
-- 10th
select max(productsPassRate) ,country from users_data GROUP BY country DESC LIMIT 10 ;
-- 11th
SELECT language, count(language) as "User Count"
FROM
users_data
GROUP BY language
order by language;
SELECT * from users_data ;
SELECT COUNT(socialProductsLiked) FROM users_data where (socialProductsLiked>0 and gender ='F');
SELECT count(productsWished) from users_data where (productsWished >0 AND gender= 'F')
union
SELECT COUNT(socialProductsLiked) FROM users_data where (socialProductsLiked>0 and gender ='F');
-- 13th
SELECT type Productssold,count(productsSold) count from users_data where ( productsSold>=1 AND gender='M')
UNION
SELECT ProductsBought,count(productsBought) from users_data where ( productsBought>=1 AND gender='M');
-- 14th
SELECT country,count(productsBought) from users_data where ( productsBought>=1 ) group by country limit 1;
-- 15th
SELECT country,count(productsSold ) from users_data where ( productsSold=0 ) GROUP BY country limit 10 ;
-- 16th
SELECT identifierHash,type,daysSinceLastLogin from users_data ORDER BY daysSinceLastLogin ASC LIMIT 110 ;
-- 17 th
SELECT identifierHash,type,daysSinceLastLogin,count(daysSinceLastLogin) from users_data
WHERE (daysSinceLastLogin>=100 AND gender='F');
-- 18TH
SELECT type,gender,count(gender)
FROM users_data Where (gender ='F'and (hasAnyApp='True'));
-- 19th
SELECT type,gender,count(gender)
FROM users_data Where (gender ='M'and (hasAnyApp='True'));
-- 20th
SELECT AVG(productsSold),AVG(productsBought),country FROM users_data WHERE gender='M' GROUP BY country ;