• Happy to help. You can make it a bit neater by putting the CASE logic near the top:

    ...

    SET @carage =CASE

    -- don't need to cast as int because that's the data type of the variable

    WHEN YEAR(GETDATE() - @carage) < 6 THEN 1

    ELSE 2

    END

    ...

    AND COALESCE(CarAgeGroup, @carage) = CarAgeGroup

    END

    John