Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize UCF quickly by SQL

Shulou Source: shulou.com Published: 2022-06-03 11:10:31 11月15日 Update

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

Tags: Users items neighbors increments questions similarity readers recommendations updates data architecture articles results consumption arrays time precision faceted business author Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple Xiaomi Microsoft Shulou Information