select case when charindex('c',C) > 0 then 1
when charindex('t',C) > 0 then 2
else 3
end as type,
count(A),
sum(B)
from table
group by case when charindex('c',C) > 0 then 1
when charindex('t',C) > 0 then 2
else 3
when charindex('t',C) > 0 then 2
else 3
end as type,
count(A),
sum(B)
from table
group by case when charindex('c',C) > 0 then 1
when charindex('t',C) > 0 then 2
else 3
when charindex('t',C) > 0 then 2
else 3
end as type,
count(A),
sum(B)
from table
group by case when charindex('c',C) > 0 then 1
when charindex('t',C) > 0 then 2
else 3 end