题解 | 推荐内容准确的用户平均评分
推荐内容准确的用户平均评分
https://www.nowcoder.com/practice/2dcac73b647247f0aef0b261ed76b47e
关键:distinct的用法。distinct为按列去重,并返回选中的列。另一种解法为先筛选出匹配正确且不重复的用户,再在user_action_tb表里进行匹配计算。
select ROUND(AVG(score),3) avg_score from( select distinct u.user_id,score from user_action_tb u left join recommend_tb r on u.user_id=r.rec_user and u.hobby_l=r.rec_info_l where rec_info_l is not NULL ) t