首页 > 试题广场 > SQL题目:
with x as (select distinct fuser from t_user), y as (select distinct fuser from t_user), a as (select  x.fuser as fuser1,y.fuser as fuser2 from  x join y on x.fuser<y.fuser  ), b as (select  x1.fuser as fuser1,y1.fuser as fuser2, count(distinct y1.fprod) as sim_cnt from t_user x1 join t_user y1 on  x1.fuser<y1.fuser  and  x1.fprod=y1.fprod  group by  x1.fuser,y1.fuser)  select b.fuser1,b.fuser2,b.sim_cnt from a left join b on a.fuser1=b.fuser1 and  a.fuser2=b.fuser2 
发表于 2018-12-18 09:31:46 回复(0)