一个SQL语句获得某人参与的帖子及在该帖得分总和
程序员文章站
2022-06-11 18:18:16
select a.*,b.sumpoint from expert_topic_index a,( select topi...
select a.*,b.sumpoint from expert_topic_index a,(
select topicid, sum(point) as sumpoint from expert_reply_index
where postusername = 'ghj1976'
group by topicid
having sum(point) > 0
) as b
where a.topicid = b.topicid
这里其实就是把一个查询的结果放到新的一个查询中了。
另外 having 对分组结果进行的查询。
select topicid, sum(point) as sumpoint from expert_reply_index
where postusername = 'ghj1976'
group by topicid
having sum(point) > 0
) as b
where a.topicid = b.topicid
这里其实就是把一个查询的结果放到新的一个查询中了。
另外 having 对分组结果进行的查询。