表字段 id username point
1 a 1
2 b 5
3 c 8
4 a 10
5 b 5
6 a -1
7 b 20
要显示结果
b 30
c 8
去掉有负数的用户a
我用户的错误语句是
rs0.open "select username, sum(point)as point from tab where username not in(select point<0 group by username) and point>0 group by username",conn,1,1
==========================================================
select username, sum(point) as point
from tab
where username not in (select username from tab where point<0 )
and point > 0
group by username
本文解决了一个特定的SQL查询问题,即如何正确地过滤并汇总正数积分的用户,避免了因包含负数积分而导致的数据不准确。通过调整子查询结构,确保只选择积分大于0的用户。
43

被折叠的 条评论
为什么被折叠?



