HAVING 搜索条件在进行分组操作之后应用

HAVING 搜索条件在进行分组操作之后应用;

如:查询帖子访问量大于15的用户id;

select t.user_id,u.name,sum(count_view) from t_topic t  
left join t_users u on t.user_id=u.id
GROUP BY user_id HAVING SUM(count_view)<15

 

posted @ 2018-04-23 15:15  王默默  阅读(247)  评论(0编辑  收藏  举报