select a.uid, b.type from tableA a, (select distinct type, uid from tabaleB) b where a.uid = b.uid order by 1
我的思路是先筛选出相同uid不同type的的记录,在在上面的结果集中统计每个uid 的type类型的数目, 最后计算type大于1的记录条数值。select count(u_id) from (select u_id, count(u_id) as num from (select distinct (type_no), u_id from tableb order by u_id) a group by u_id) b where num > 1;
from tableA a, (select distinct type, uid from tabaleB) b
where a.uid = b.uid
order by 1
最后计算type大于1的记录条数值。select count(u_id)
from (select u_id, count(u_id) as num
from (select distinct (type_no), u_id from tableb order by u_id) a
group by u_id) b
where num > 1;