Commit e793a5e2 authored by Nadine Steinmetz's avatar Nadine Steinmetz
Browse files

Add new file

parents
Pipeline #215 failed with stages
How many different customers were in the first quarter of 1997? 1 SELECT COUNT(DISTINCT(customer.customer_id) ) FROM sales_fact INNER JOIN customer ON customer.customer_id = sales_fact.customer_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE time_by_day.quarter = 'Q1' AND time_by_day.the_year = '1997' ;
What were the total sales from March 1997? 1 SELECT SUM(sales_fact.store_sales) , SUM(sales_fact.unit_sales), SUM(sales_fact.store_cost) FROM sales_fact INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE time_by_day.the_month = 'March' AND time_by_day.the_year = '1997' ;
How many products were on stock in the last month of 1997? 4 SELECT SUM(inventory_fact.units_ordered) - SUM(inventory_fact.units_shipped) FROM inventory_fact INNER JOIN product product ON product.product_id = inventory_fact.product_id INNER JOIN time_by_day time_by_day ON time_by_day.time_id = inventory_fact.time_id WHERE time_by_day.the_month = 'December' AND time_by_day.the_year = '1997' ;
How many different stores in USA have sold beverages in year 1997? 1 SELECT COUNT(DISTINCT(store.store_id) ) FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE store.store_country = 'USA' AND product_class.product_department = 'Beverages' AND time_by_day.the_year = '1997' ;
Show for each store in Mexico the total sales in the second quarter of 1998? 2 SELECT DISTINCT(store.store_id) , SUM(sales_fact.store_sales) , SUM(sales_fact.unit_sales), SUM(sales_fact.store_cost) FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE store.store_country = 'Mexico' AND time_by_day.quarter = 'Q2' AND time_by_day.the_year = '1998' GROUP BY store.store_id ORDER BY SUM(sales_fact.store_sales) DESC ;
How many unique customers were in Seattle in 1997? 1 SELECT COUNT(DISTINCT(customer.customer_id) ) FROM sales_fact INNER JOIN customer ON customer.customer_id = sales_fact.customer_id INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE store.store_city = 'Seattle' AND time_by_day.the_year = '1997' ;
How many types of products were sold in the third quarter of 1998 in each of the Canadian stores? 2 SELECT COUNT(DISTINCT(product.product_id) ) , store.store_id FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id INNER JOIN store ON store.store_id = sales_fact.store_id WHERE time_by_day.quarter = 'Q3' AND time_by_day.the_year = '1998' AND store.store_country = 'Canada' GROUP BY store.store_id ORDER BY COUNT(DISTINCT(product.product_id) ) DESC ;
How many Magazines were sold in Vancouver Canada in 1998? 1 SELECT COUNT(product.product_id) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_category = 'Magazines' AND store.store_city = 'Vancouver' AND store.store_country = 'Canada' AND time_by_day.the_year = '1998' ;
How much meat was sold in Mexico in 1998? 1 SELECT COUNT(product.product_id) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_department = 'Meat' AND store.store_country = 'Mexico' AND time_by_day.the_year = '1998' ;
Show the total sales from 1998 from the Deluxe Supermarket stores located in Canada? 2 SELECT SUM(sales_fact.store_sales) , SUM(sales_fact.unit_sales), SUM(sales_fact.store_cost) , store.store_id FROM sales_fact INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id INNER JOIN store ON store.store_id = sales_fact.store_id WHERE time_by_day.the_year = '1998' AND store.store_type = 'Deluxe Supermarket' AND store.store_country = 'Canada' GROUP BY store.store_id ORDER BY SUM(sales_fact.store_sales) DESC ;
What were the total sales in Seattle in 1997? 1 SELECT SUM(sales_fact.store_sales) , SUM(sales_fact.unit_sales), SUM(sales_fact.store_cost) FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE store.store_city = 'Seattle' AND time_by_day.the_year = '1997'
Show for each brand the total sales in 1998. 2 SELECT product.brand_name , SUM(sales_fact.store_sales) , SUM(sales_fact.unit_sales), SUM(sales_fact.store_cost) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE time_by_day.the_year = '1998' GROUP BY product.brand_name ORDER BY SUM(sales_fact.store_sales) DESC ;
How many snack foods were sold in Canada in 1998. 1 SELECT COUNT(product.product_id) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_department = 'Snack Foods' AND store.store_country = 'Canada' AND time_by_day.the_year = '1998' ;
Show the stores from Canada which sold bread in the second quarter of 1998. 1 SELECT DISTINCT(store.store_id) FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE store.store_country = 'Canada' AND product_class.product_category = 'Bread' AND time_by_day.quarter = 'Q2' AND time_by_day.the_year = '1998' ORDER BY store.store_id ASC ;
How much bread was sold per city in 1997? 2 SELECT COUNT(product.product_id) , store.store_city FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_category = 'Bread' AND time_by_day.the_year = '1997' GROUP BY store.store_city ORDER BY COUNT(product.product_id) DESC ;
What were the average sales for each store from Mexico in the first quarter of 1998? 2 SELECT AVG(sales_fact.store_sales) , AVG(sales_fact.unit_sales), AVG(sales_fact.store_cost) , store.store_id FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE store.store_country = 'Mexico' AND time_by_day.quarter = 'Q1' AND time_by_day.the_year = '1998' GROUP BY store.store_id ORDER BY AVG(sales_fact.store_sales) DESC ;
What were the maximum costs for each store located in Canada per month in the year 1998? 2 SELECT MAX(expense_fact.amount) , store.store_id , time_by_day.month_of_year FROM expense_fact INNER JOIN store ON store.store_id = expense_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = expense_fact.time_id WHERE store.store_country = 'Canada' AND time_by_day.the_year = '1998' GROUP BY store.store_id, time_by_day.month_of_year ORDER BY MAX(expense_fact.amount) DESC ;
In which month the most bread was sold? 2 SELECT time_by_day.month_of_year , COUNT(product.product_id) FROM sales_fact INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id WHERE product_class.product_category = 'Bread' GROUP BY time_by_day.month_of_year ORDER BY COUNT(product.product_id) DESC ;
Which store sold more pasta than Seattle in January 1998? 3 SELECT DISTINCT(store.store_id) , COUNT(product.product_id) FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_subcategory = 'Pasta' AND time_by_day.the_month = 'January' AND time_by_day.the_year = '1998' GROUP BY store.store_id HAVING (COUNT(product.product_id) ) > (SELECT COUNT(product.product_id) FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_subcategory = 'Pasta' AND time_by_day.the_month = 'January' AND time_by_day.the_year = '1998' AND store.store_city = 'Seattle' ) ORDER BY COUNT(product.product_id) DESC ;
In which month was sold the least bread in Seattle? 3 SELECT time_by_day.month_of_year , COUNT(product.product_id) FROM sales_fact INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN store ON store.store_id = sales_fact.store_id WHERE product_class.product_category = 'Bread' AND store.store_city = 'Seattle' GROUP BY time_by_day.month_of_year ORDER BY COUNT(product.product_id) ASC ;
Where was the most bread sold in 1997? 3 SELECT DISTINCT(region.region_id) , COUNT(product.product_id) FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN region ON region.region_id = store.region_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_category = 'Bread' AND time_by_day.the_year = '1997' GROUP BY region.region_id ORDER BY COUNT(product.product_id) DESC ;
How many products were ordered? 1 SELECT COUNT(product.product_id) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id ;
How many items remain on warehouse shelves at the end of the year? 4 SELECT SUM(inventory_fact.units_ordered) - SUM(inventory_fact.units_shipped) , warehouse.warehouse_id FROM inventory_fact INNER JOIN warehouse ON warehouse.warehouse_id = inventory_fact.warehouse_id INNER JOIN time_by_day ON time_by_day.time_id = inventory_fact.time_id WHERE time_by_day.the_month = 'December' GROUP BY warehouse.warehouse_id ORDER BY SUM(inventory_fact.units_ordered) , SUM(inventory_fact.units_shipped) DESC ;
How much were the expenses for the stores located in USA in the first quarter of 1997? 1 SELECT COUNT(store.store_id) FROM inventory_fact INNER JOIN store ON store.store_id = inventory_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = inventory_fact.time_id WHERE store.store_country = 'USA' AND time_by_day.quarter = 'Q1' AND time_by_day.the_year = '1997' ;
What were the total sales per store in May 1998 compared to January 1997? 3 SELECT t0.store_id, t0.store_sales as store_sales_May1998, t0.unit_sales as unit_sales_May1998, t0.store_cost as store_cost_May1998 , t1.store_id, t1.store_sales as store_sales_January1997, t1.unit_sales as unit_sales_January1997, t1.store_cost as store_cost_January1997 FROM (SELECT SUM(sales_fact.store_sales) as store_sales , SUM(sales_fact.unit_sales) as unit_sales , SUM(sales_fact.store_cost) as store_cost , store.store_id FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE time_by_day.the_month = 'May' AND time_by_day.the_year = '1998' GROUP BY store.store_id) as t0 FULL OUTER JOIN (SELECT SUM(sales_fact.store_sales) as store_sales , SUM(sales_fact.unit_sales) as unit_sales , SUM(sales_fact.store_cost) as store_cost , store.store_id FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE time_by_day.the_month = 'January' AND time_by_day.the_year = '1997' GROUP BY store.store_id) as t1 ON t0.store_id = t1.store_id ORDER BY t0.store_id, t1.store_id ;
What were the total sales per product class in May 1998 compared to January 1997? 3 SELECT t0.product_class_id, t0.store_sales as store_sales_May1998, t0.unit_sales as unit_sales_May1998, t0.store_cost as store_cost_May1998 , t1.product_class_id, t1.store_sales as store_sales_January1997, t1.unit_sales as unit_sales_January1997, t1.store_cost as store_cost_January1997 FROM (SELECT SUM(sales_fact.store_sales) as store_sales , SUM(sales_fact.unit_sales) as unit_sales , SUM(sales_fact.store_cost) as store_cost , product_class.product_class_id FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE time_by_day.the_month = 'May' AND time_by_day.the_year = '1998' GROUP BY product_class.product_class_id) as t0 FULL OUTER JOIN (SELECT SUM(sales_fact.store_sales) as store_sales , SUM(sales_fact.unit_sales) as unit_sales , SUM(sales_fact.store_cost) as store_cost , product_class.product_class_id FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE time_by_day.the_month = 'January' AND time_by_day.the_year = '1997' GROUP BY product_class.product_class_id) as t1 ON t0.product_class_id = t1.product_class_id ORDER BY t0.product_class_id, t1.product_class_id ;
What were the total costs for bread in may 1997? 1 SELECT SUM(product.product_id) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_category = 'Bread' AND time_by_day.the_year = '1997' ;
How many units by Jeffers were in stock in the first month of 1997? 4 SELECT SUM(inventory_fact.units_ordered) - SUM(inventory_fact.units_shipped) FROM inventory_fact INNER JOIN product ON product.product_id = inventory_fact.product_id INNER JOIN time_by_day ON time_by_day.time_id = inventory_fact.time_id WHERE product.brand_name = 'Jeffers' AND time_by_day.the_month = 'January' AND time_by_day.the_year = '1997' ORDER BY SUM(inventory_fact.units_ordered) , SUM(inventory_fact.units_shipped) DESC ;
How many paper wipes were sold in January 1997? 1 SELECT COUNT(product.product_id) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_subcategory = 'Paper Wipes' AND time_by_day.the_month = 'January' AND time_by_day.the_year = '1997' ;
In which month less bread was sold than in January 1997? 3 SELECT time_by_day.month_of_year , COUNT(product.product_id) FROM sales_fact INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id WHERE product_class.product_category = 'Bread' AND time_by_day.the_year = '1997' GROUP BY time_by_day.month_of_year HAVING (COUNT(product.product_id) ) < (SELECT COUNT(product.product_id) FROM sales_fact INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id WHERE product_class.product_category = 'Bread' AND time_by_day.the_year = '1997' AND time_by_day.the_month = 'January' ) ORDER BY COUNT(product.product_id) DESC ;
How many different products were sold in October 1998? 1 SELECT COUNT(DISTINCT(product.product_id) ) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE time_by_day.the_month = 'October' AND time_by_day.the_year = '1998' ;
What is the net weight of bread that was sold most in February 1998? 3 SELECT product.net_weight, SUM(sales_fact.unit_sales) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_category = 'Bread' AND time_by_day.the_month = 'February' AND time_by_day.the_year = '1998' GROUP BY product.net_weight ORDER BY SUM(sales_fact.unit_sales) DESC;
What were the total sales per region in 1998? 2 SELECT SUM(sales_fact.store_sales) , SUM(sales_fact.unit_sales), SUM(sales_fact.store_cost) , region.sales_region FROM sales_fact INNER JOIN store ON store.store_id = sales_fact.store_id INNER JOIN region ON region.region_id = store.region_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE time_by_day.the_year = '1998' GROUP BY region.sales_region ORDER BY SUM(sales_fact.store_sales) DESC ;
What is the highest sales for bread in May 1998? 2 SELECT DISTINCT(MAX(sales_fact.store_sales) ) , MAX(sales_fact.unit_sales), MAX(sales_fact.store_cost) FROM sales_fact INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id WHERE product_class.product_category = 'Bread' AND time_by_day.the_month = 'May' AND time_by_day.the_year = '1998' ;
What were the total sales for pasta in the business year 1997/98? 4 SELECT SUM(sales_fact.unit_sales) FROM sales_fact INNER JOIN time_by_day ON time_by_day.time_id = sales_fact.time_id INNER JOIN product ON product.product_id = sales_fact.product_id INNER JOIN product_class ON product_class.product_class_id = product.product_class_id WHERE (time_by_day.month_of_year > 8 AND time_by_day.the_year = '1997' AND product_class.product_subcategory = 'Pasta') OR (time_by_day.month_of_year < 9 AND time_by_day.the_year = '1998' AND product_class.product_subcategory = 'Pasta') ;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment