语句如下:
select count(*) from
(select t.mobile tm,sum(t.jifen)ts from t_jifen_detail t
where t.jifen>0 group by t.mobile)A,
(select j.mobile jm,sum(j.jifen)js from t_jifen_detail j
group by j.mobile)B
where A.ts=B.js;
...全文
1276打赏收藏
谁来帮我优化一下我的sql语句???
语句如下: select count(*) from (select t.mobile tm,sum(t.jifen)ts from t_jifen_detail t where t.jifen>0 group by t.mobile)A, (select j.mobile jm,sum(j.jifen)js from t_jifen_detail j group by j.mobile)B where A.ts=B.js;
Select Count(1)
From (Select j.Mobile Jm,
Sum(j.Jifen) Js,
Sum(Decode(Sign(Jifen), 1, Jifen, 0)) As Ts
From t_Jifen_Detail j
Group By j.Mobile)
Where Js = Ts
select mobile ,sum(jifen) from
t_jifen_detail
where mobile not in (select mobile from t_jifen_detail where jifen<=0 and rownum=1)
group by mobile
---------------------------------------------------
select mobile ,sum(jifen) from
t_jifen_detail a
where not exists(select * from t_jifen_detail b where a.mobile=b.mobile and b.jifen<=0)
group by mobile