SqlServer
SqlServer
---- Display the details of the product where product type is coffee.
Select * from Product where Product_Type='Coffee';
---- Display the details where total expenses are greater than 40.
Select * from fact where Total_Expenses>40 order by Total_Expenses desc;
--- Display the average total expense of each product ID on an individual date.
Select AVG(Total_Expenses) as Avg_Total_Expenses,ProductId,date from Fact group by
ProductId,date order by ProductId;
---- Display the table with the following attributes such as date,
productID,product_type, product, sales, profit, state, area_code.
Select
F.date,P.ProductId,P.Product_Type,P.Product,F.Sales,F.Profit,L.state,L.area_Code
from Product P join fact F on P.ProductId=F.ProductId join Location L on
F.Area_Code=L.Area_Code;
--- Display the rank without any gap to show the sales wise rank.
Select PRODUCTId,Sales,Profit, DENSE_RANK() over (order by Sales desc) as
Sales_Rank FROM fact;
---- Find the state wise profit and sales along with the product name.