2003年12月23日 11:52 href="http://blog.joycode.com/ghj/Services/Pingback.aspx" rel="pingback" />
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 对分组结果进行的查询。
反馈
# 回复: 一个SQL语句获得某人参与的帖子及在该帖得分总和
2003-12-27 12:07 by
这个好像sql server 7.0支持的不太好,排序有问题的.
# 回复: 一个SQL语句获得某人参与的帖子及在该帖得分总和
2003-12-27 13:24 by
不清楚,已经n就不考虑SQL Server 7.0 了。
# 回复: 一个SQL语句获得某人参与的帖子及在该帖得分总和
2004-2-5 13:02 by
我晕,太难了
# 回复: 一个SQL语句获得某人参与的帖子及在该帖得分总和
2004-5-1 10:28 by
不会吧,这样简单的还算技术心得!
# re: 一个SQL语句获得某人参与的帖子及在该帖得分总和
2004-10-29 17:09 by
To:qaz
在别人分享自己技术心得时,即使是很小的地方也会别人带来好处
简不简单 和 是否算技术心得无关
会了确实简单,但当初不会时呢
# re: 一个SQL语句获得某人参与的帖子及在该帖得分总和
2005-6-3 18:28 by
To:qaz老兄,你说的一点没错。能够将自己的东西拿出来供大家分享,这本来就是一种难能可贵人精神,
# re: 一个SQL语句获得某人参与的帖子及在该帖得分总和
2005-7-25 13:14 by
建议使用JOIN而不是WHERE =的方式来写SQL。
# re: 一个SQL语句获得某人参与的帖子及在该帖得分总和
2006-3-28 1:31 by
do not use having, try this
select topicid,topic,(
select sum(score) from t_reply r where r.topicid=t.topicid and r.userid=1100
) as score from t_topic t where score > 0 group by topicid