表有三个字段:id,ctype,ip。要实现以下脚本的功能,咋处理?select ctype,count(distinct (ip)) ct
from(
select
case when ctype in(
select ctype from (
select ctype,count(DISTINCT ip) ct from test1 group by ctype) t
order by ct desc LIMIT 3
) then '0' else ctype end ctype,ip
from test1) t
group by ctype
order by ct desc;
select ctype,count(DISTINCT ip) ct from test1 group by ctype) t
order by ct desc LIMIT 3
这个语句写到临时表里面。