Solutions: 1. SELECT SKU_Code, Category, Weight, RANK() OVER (PARTITION BY Category ORDER BY Weight DESC) AS Weight_Rank FROM Products; 2. SELECT ROW_NUMBER() OVER (ORDER BY Date) AS Row_Num, Sale_ID, Date, Gross_Amount FROM Sales_Transactions; 3. WITH CustomerSpending AS ( SELECT c.Customer_ID, c.Customer_Name, SUM(s.Gross_Amount) AS Total_Spent FROM Customers c JOIN Sales_Transactions s ON c.Customer_ID = s.Customer_ID GROUP BY c.Customer_ID, c.Customer_Name ) SELECT Customer_ID, Customer_Name, Total_Spent, DENSE_RANK() OVER (ORDER BY Total_Spent DESC) AS Spend_Rank FROM CustomerSpending; 4. WITH RankedProducts AS ( SELECT Category, SKU_Code, Weight, RANK() OVER (PARTITION BY Category ORDER BY Weight DESC) AS Weight_Rank FROM Products ) SELECT * FROM RankedProducts WHERE Weight_Rank <= 3; 5. SELECT Operation_ID, Operation_Type, ROW_NUMBER() OVER (PARTITION BY Operation_Type ORDER BY Operation_ID) AS Seq_Num FROM Warehouse_Ops; 6. SELECT Sale_ID, EXTRACT(MONTH FROM Date) AS Month, Gross_Amount, RANK() OVER (PARTITION BY EXTRACT(MONTH FROM Date) ORDER BY Gross_Amount DESC) AS Monthly_Rank FROM Sales_Transactions; 7. SELECT s.SKU_Code, s.Date, s.Gross_Amount AS Daily_Sales, SUM(s.Gross_Amount) OVER (PARTITION BY s.SKU_Code ORDER BY s.Date) AS Running_Total FROM Sales_Transactions s JOIN Products p ON s.SKU_Code = p.SKU_Code; 8. WITH InventoryValues AS ( SELECT p.Category, i.SKU_Code, (i.Stock_Qty * pr.TP_Price) AS Inventory_Value, PERCENT_RANK() OVER (PARTITION BY p.Category ORDER BY (i.Stock_Qty * pr.TP_Price) DESC) AS Value_Percentile FROM Inventory i JOIN Pricing pr ON i.SKU_Code = pr.SKU_Code JOIN Products p ON i.SKU_Code = p.SKU_Code ) SELECT * FROM InventoryValues WHERE Value_Percentile <= 0.1; 9. WITH CustomerPurchases AS ( SELECT c.Customer_ID, c.Customer_Name, MAX(s.Gross_Amount) AS Max_Purchase FROM Customers c JOIN Sales_Transactions s ON c.Customer_ID = s.Customer_ID GROUP BY c.Customer_ID, c.Customer_Name ) SELECT Customer_ID, Customer_Name, Max_Purchase, RANK() OVER (ORDER BY Max_Purchase DESC) AS Purchase_Rank FROM CustomerPurchases; 10. WITH MonthlySales AS ( SELECT EXTRACT(MONTH FROM Date) AS Month, SUM(Gross_Amount) AS Monthly_Sales, LAG(SUM(Gross_Amount)) OVER (ORDER BY EXTRACT(MONTH FROM Date)) AS Previous_Month_Sales FROM Sales_Transactions GROUP BY EXTRACT(MONTH FROM Date) ) SELECT Month, Monthly_Sales, Previous_Month_Sales, (Previous_Month_Sales - Monthly_Sales) AS Sales_Drop FROM MonthlySales ORDER BY Sales_Drop DESC LIMIT 1; 11. WITH ProductSales AS ( SELECT p.SKU_Code, p.Design_No, COALESCE(SUM(s.Quantity), 0) AS Total_Sold FROM Products p LEFT JOIN Sales_Transactions s ON p.SKU_Code = s.SKU_Code GROUP BY p.SKU_Code, p.Design_No ) SELECT SKU_Code, Design_No, Total_Sold, PERCENT_RANK() OVER (ORDER BY Total_Sold) AS Sales_Percentile FROM ProductSales; 12. WITH CustomerDates AS ( SELECT DISTINCT Customer_ID, Date FROM Sales_Transactions ), DateGroups AS ( SELECT Customer_ID, Date, DATE_ADD(Date, -ROW_NUMBER() OVER (PARTITION BY Customer_ID ORDER BY Date)) AS Date_Group FROM CustomerDates ) SELECT Customer_ID, COUNT(*) AS Consecutive_Days FROM DateGroups GROUP BY Customer_ID, Date_Group HAVING COUNT(*) > 1; 13. WITH CategoryPrices AS ( SELECT p.Category, AVG(s.Gross_Amount/s.Quantity) AS Avg_Sale_Price FROM Products p JOIN Sales_Transactions s ON p.SKU_Code = s.SKU_Code GROUP BY p.Category ) SELECT Category, Avg_Sale_Price, RANK() OVER (ORDER BY Avg_Sale_Price DESC) AS Category_Rank FROM CategoryPrices; 14. WITH MonthlyRanks AS ( SELECT c.Customer_ID, c.Customer_Name, EXTRACT(MONTH FROM s.Date) AS Month, SUM(s.Gross_Amount) AS Monthly_Spend, PERCENT_RANK() OVER (PARTITION BY EXTRACT(MONTH FROM s.Date) ORDER BY SUM(s.Gross_Amount) DESC) AS Spend_Percentile FROM Customers c JOIN Sales_Transactions s ON c.Customer_ID = s.Customer_ID GROUP BY c.Customer_ID, c.Customer_Name, EXTRACT(MONTH FROM s.Date) ) SELECT Customer_ID, Customer_Name, COUNT(*) AS Top_Months FROM MonthlyRanks WHERE Spend_Percentile <= 0.25 GROUP BY Customer_ID, Customer_Name HAVING COUNT(*) = (SELECT COUNT(DISTINCT EXTRACT(MONTH FROM Date)) FROM Sales_Transactions); 15. WITH DailySales AS ( SELECT Date, SUM(Gross_Amount) AS Daily_Sales FROM Sales_Transactions GROUP BY Date ) SELECT Date, Daily_Sales, AVG(Daily_Sales) OVER (ORDER BY Date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS Moving_Avg_7day FROM DailySales;