SELECT bl.name location,COUNT(t.id) current_month_sales,LAG(COUNT(t.id)) OVER (PARTITION BY bl.id ORDER BY DATE_FORMAT(t.transaction_date,"%Y-%m")) prev_month_sales FROM business_locations bl JOIN transactions t ON bl.id=t.location_id WHERE t.type="sell" GROUP BY bl.id,bl.name,DATE_FORMAT(t.transaction_date,"%Y-%m") ORDER BY (current_month_sales-prev_month_sales)/NULLIF(prev_month_sales,0) DESC;