题解 | 推荐内容准确的用户平均评分

推荐内容准确的用户平均评分

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

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务