您可以在下面的查询中使用,但是will not show thegaps
如果您要保留空白,请使用Linoff的答案:
select t.txt, count(t.age) from
(select
case
when age<11 then concat(age ,' year')
else 'more than 10'
end txt, age
from your_table)t
group by t.txt
order by 1
在这种情况下,如何仅减少一个SQL查询
您可以在下面的查询中使用,但是will not show thegaps
如果您要保留空白,请使用Linoff的答案:
select t.txt, count(t.age) from
(select
case
when age<11 then concat(age ,' year')
else 'more than 10'
end txt, age
from your_table)t
group by t.txt
order by 1