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