0% found this document useful (0 votes)
1K views

SQL New Case Study Ques

The document presents a case study involving SQL queries on 3 datasets - a FactTable with sales and expense data, a ProductTable with product details, and a LocationTable with state and market information. It provides 27 sample queries to analyze factors like state-wise sales and profits, highest costs, average expenses and inventories by product or location, and more, requiring joins across the tables.

Uploaded by

Joyce George
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

SQL New Case Study Ques

The document presents a case study involving SQL queries on 3 datasets - a FactTable with sales and expense data, a ProductTable with product details, and a LocationTable with state and market information. It provides 27 sample queries to analyze factors like state-wise sales and profits, highest costs, average expenses and inventories by product or location, and more, requiring joins across the tables.

Uploaded by

Joyce George
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL - Case Study

[email protected]

+91-7022374614

US: 1-800-216-8930 (Toll-Free)


Problem Statement:

You are a database administrator. You want to use the data to answer a few questions about
your customers, especially about the sales and profit coming from different states, Money spent
in marketing and various other factors such as COGS, Budget profit etc.You plan on using
these insights to help him decide whether which items is being sold most Additionally he needs
help to generate some basic datasets so his team can easily inspect the data without needing to
use SQL.You have provided the sample of his overall customer data due to privacy issues - but
you hope that these samples are enough for you to write fully functioning SQL queries to help
him answer his questions.

Dataset :

The 3 key datasets for this case study:

● FactTable

The FactTable has 13 columns mentioned below and 4200 rows.


Profit, Margin, Sales, COGS, Total Expenses, Marketing, Inventory, Budget, Profit, Budget
COGS, Budget Margin, Budget Sales, Area Code, and ProductID
Note - COGS stands for Cost of Goods Sold

● ProductTable

The ProductTable has four columns named Product Type, Product, ProductId, and Type. It has
13 rows, which can be broken down into further details to retrieve the information mentioned in
the FactTable.

● LocationTable

Finally, the LocationTable has 156 rows and follows a similar approach to ProductTable and has
four columns named Area Code, State, Market, and Market Size.
1) How many states are there where products have been sold ?
2) How many products are of regular type ?
3) How much spending has been done on marketing of product id 1
4) What is the minimum sales of a product ?
5) Display max Cost of Good Sold(COGS).
6) Display the Details of the productid where product type is coffee
7) Display the details where total_expenses is greater than 40.
8) What is the average sales in Area_Code 719 ?
9) Find out the total profit generated by Colorado state.
10) Display the average inventory for each product id.
11) Display state in a sequential order in a location table.
12) Display the average budget margin of the store where average budget margin should be
greater than 100.
13) What is the total sales done on date 2010-01-01
14) Display the average total expense of each product id on individual date
15) Display the table with the following attributes such as
Date, productid, product_type, product, Sales, profit, state, area_code
16) Display the rank without any gap to show the Sales wise rank.
17) Find the State wise Profit and Sales.
18) Find the State wise Profit and Sales along with the Product Name.
19) If there is an increase in sales of 5%. Calculate the increased sales.
20) Find the maximum profit along with the Product id and Product Type.
21) Create a Stored Procedure to fetch the result according to the product type from Product.
22) Write a query by creating a condition in which if the total expenses is less than 60 then it is a
profit or else loss.
23) Give the total weekly sales value with the Date and productid details. Use roll-up to pull the
data in hierarchical order.
24) Apply union and intersection operator on the tables which consist of attribute area code.
25) Create a user-defined function for the product table to fetch a particular product type based
upon the user’s preference.
26) Change the product type from coffee to tea where product id is 1 and undo it.
27) Display the Date, productid and sales where total expenses are between 100 to 200.
28) Delete the records in the product table for regular type.
29) Display the ASCII value of the fifth character from the column product.

You might also like