您现在的位置是:网站首页> 编程资料编程资料

一个SQL语句获得某人参与的帖子及在该帖得分总和_MsSql_

2023-05-26 528人已围观

简介 一个SQL语句获得某人参与的帖子及在该帖得分总和_MsSql_

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 对分组结果进行的查询。

-六神源码网