表member会员表有字段 id t tuijian locked sd
tuijian字段是id的推荐人,,要统计locked=1 并且 sd=0 然后sum(t)>50 的人有多少个。应该怎么写?
也就是
select * from member where locked=1 and sd=0 and 这里是要连接这个来判断(select sum(t) from member where tuijian=id)>50
------解决方案--------------------
try this,
select *
from member a
where a.locked=1 and a.sd=0
and (select sum(b.t) from member b where b.tuijian=a.id)>50