SQL Practice Problems - Day 8 Focus: Time-Series Window Functions 1 - Show each sale with the previous sale amount for the same product. Input Table: Sales_Transactions Output: Sale_ID, SKU_Code, Gross_Amount, Previous_Amount 2 - Calculate 3-day moving average of sales amounts. Input Table: Sales_Transactions Output: Date, Daily_Sales, Moving_Avg_3day 3 - Find the next sale date for each customer. Input Tables: Customers, Sales_Transactions Output: Customer_ID, Current_Sale_Date, Next_Sale_Date 4 - Compute cumulative sales by product category over time. Input Tables: Products, Sales_Transactions Output: Category, Date, Daily_Sales, Running_Total 5 - Identify sales with amounts that increased by more than 50% from previous sale. Input Table: Sales_Transactions Output: Sale_ID, Current_Amount, Previous_Amount, Pct_Increase 6 - Calculate running inventory changes from warehouse operations. Input Tables: Warehouse_Ops Output: Operation_ID, SKU_Code, Quantity, Running_Inventory 7 - Show monthly sales with difference from previous month. Input Table: Sales_Transactions Output: Month, Monthly_Sales, Previous_Month_Sales, Sales_Difference 8 - Find products with consistent weekly sales patterns. Input Tables: Products, Sales_Transactions Output: SKU_Code, Weekly_Sales_Variance 9 - Compute 7-day rolling sum of sales quantities. Input Table: Sales_Transactions Output: Date, Daily_Quantity, Rolling_Sum_7day 10 - Identify the longest gap between purchases for each customer. Input Tables: Customers, Sales_Transactions Output: Customer_ID, Max_Days_Between_Purchases 11 - Calculate the average time between purchases for each product. Input Tables: Products, Sales_Transactions Output: SKU_Code, Avg_Days_Between_Sales 12 - Show sales with the percentage change from the previous day's total sales. Input Table: Sales_Transactions Output: Date, Daily_Sales, Pct_Change_From_Previous_Day 13 - Find products with increasing sales for 3 consecutive months. Input Tables: Products, Sales_Transactions Output: SKU_Code, Month1_Sales, Month2_Sales, Month3_Sales 14 - Compute the exponential moving average (α=0.3) of daily sales. Input Table: Sales_Transactions Output: Date, Daily_Sales, EMA_03 15 - Identify the best selling day of week for each product category. Input Tables: Products, Sales_Transactions Output: Category, Best_Day, Avg_Sales_On_Best_Day