select case when total <= 10 then total as tier1, case when total between 10 and 20 then total as tier2 , case when total > 20 then total as tier3 , member_ref from ( select sum(amount) as Total, member_ref, description from payments where description like '%Test%' group by member_ref, description ) X>Hi
>select max(total), ; > member_ref ; > from ( ; > select sum(amount) as Total, ; > member_ref, ; > description ; > from payments ; > where description like '%Test%' ; > group by member_ref, description ; > ) X ; > group by 2 > >>