首頁  >  文章  >  資料庫  >  一个SQL语句获得某人参与的帖子及在该帖得分总和

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

WBOY
WBOY原創
2016-06-07 17:57:06824瀏覽

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

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 对分组结果进行的查询。
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn