0% found this document useful (0 votes)
25 views2 pages

Case STUDY 1

SQL

Uploaded by

Kavita Bani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Case STUDY 1

SQL

Uploaded by

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

1. Display the number of states present in the LocationTable.

ANS.
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 the max Cost of Good Sold (COGS).
6. Display the details of the product where product type is coffee.
7. Display the details where total expenses are 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.
ANS. select * from location order by state

12. Display the average budget of the Product where the average budget
margin should be greater than 100.
ANS. select avg(budget_margin) as avg from fact where budget margin
>100

13. What is the total sales done on date 2010-01-01?


ANS. select sum(sales) from fact where date=’2010-01-01’

14. Display the average total expense of each product ID on an individual


date.
ANS. select productid, date, avg(total_expenses) as avg from fact group
by productid, date

15. Display the table with the following attributes such as date, productID,
product_type, product, sales, profit, state, area_code.
ANS. select fact.productID

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 increasedsales.
20. Find the maximum profit along with the product ID and producttype.
21. Create a stored procedure to fetch the result according to the product
type
from Product Table.
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 product ID 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, product ID 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 columnProduct.

You might also like