SELECT CASE WHEN line_discount_amount=0 THEN "No Discount" WHEN line_discount_amount<=10 THEN "0-10%" WHEN line_discount_amount<=25 THEN "11-25%" ELSE "26%+" END discount_range,COUNT(*) transactions,SUM(quantity) units FROM transaction_sell_lines tsl JOIN transactions t ON tsl.transaction_id=t.id WHERE t.type="sell" GROUP BY 1;