How to realize UCF quickly by SQL
This article mainly introduces SQL how to quickly achieve UCF, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
SQLselect uid1,uid2,sim from (select uid1,uid2, cnt12 / sqrt (cnt1*cnt2) sim, row_number () over (partition by uid1 order by cnt12 / sqrt (cnt1*cnt2) desc) sim_rn from (select a.uid uid1, b.uid uid2 Count (a.iid) cnt12 from tb_behavior a join tb_behavior b on a.iid = b.iid where a.uid b.uid group by a.uid B.uid) a12 join (select uid,count (iid) cnt1 from tb_behavior group by uid) A1 on a12.uid1 = a1.uid join (select uid) Count (iid) cnt2 from tb_behavior group by uid) a2 on a12.uid1 = a2.uid) tb_neighbour where sim > 0.1 and sim_rn