with a as( select ss.store_id, store_name, city, ss.sku_id, ifnull(sum(qty),0) as last7d_qty, ifnull(round(sum(qty)/7,2),0.00) as avg_daily_qty, ss.stock_qty, CASE WHEN round(sum(qty)/7,2)>0 THEN ROUND(ss.stock_qty/round(sum(qty)/7,2), 1) ELSE NULL END as coverage_days, ROW_NUMBER() over(partitio...