vv_sqlcmd := 'insert into tsd_subs_points_'|| vv_month ||'( '||
' SUBS_PTS_ID, '||--1
' CURRENT_PTS, '||--2
' ACC_PTS, '||--3
' SUBS_INSTANCE_ID, '||--4
' STATUS, '||--5
' CONSUME_PTS, '||--6
' ONNET_PTS, '||--7
' AWARD_PTS, '||--8
' CREDIT_PTS) '||--9
' select b.SUBS_PTS_ID, '||--1
' b.CURRENT_PTS, '||--2
' a.ACC_PTS, '||--3
' a.SUBS_ID, '||--4
' a.STATUS, '||--5
' sum(decode(b.pts_typ_id,''消费'',''消费'',0)), '||--6
' sum(decode(b.pts_typ_id,''在网'',''在网'',0)), '||--7
' sum(decode(b.pts_typ_id,''奖励'',''奖励'',0)), '||--8
' sum(decode(b.pts_typ_id,''信用'',''信用'',0)) '||--9
' from subs_points a, '||
' subs_typ_points b '||
' group by b.pts_typ_id '||
' where a.subs_pts_id=b.subs_pts_id ';
execute immediate vv_sqlcmd;
commit;
本人初学者,想问问高手们这个应该怎么写,我知道group by后面应该接having,但是我需要后面的条件,应该怎么改。后者有没有别的写法。很想给点分,但是我没有,谢谢好心人。
' SUBS_PTS_ID, '||--1
' CURRENT_PTS, '||--2
' ACC_PTS, '||--3
' SUBS_INSTANCE_ID, '||--4
' STATUS, '||--5
' CONSUME_PTS, '||--6
' ONNET_PTS, '||--7
' AWARD_PTS, '||--8
' CREDIT_PTS) '||--9
' select b.SUBS_PTS_ID, '||--1
' b.CURRENT_PTS, '||--2
' a.ACC_PTS, '||--3
' a.SUBS_ID, '||--4
' a.STATUS, '||--5
' sum(decode(b.pts_typ_id,''消费'',''消费'',0)), '||--6
' sum(decode(b.pts_typ_id,''在网'',''在网'',0)), '||--7
' sum(decode(b.pts_typ_id,''奖励'',''奖励'',0)), '||--8
' sum(decode(b.pts_typ_id,''信用'',''信用'',0)) '||--9
' from subs_points a, '||
' subs_typ_points b '||
' group by b.pts_typ_id '||
' where a.subs_pts_id=b.subs_pts_id ';
execute immediate vv_sqlcmd;
commit;
本人初学者,想问问高手们这个应该怎么写,我知道group by后面应该接having,但是我需要后面的条件,应该怎么改。后者有没有别的写法。很想给点分,但是我没有,谢谢好心人。
' where a.subs_pts_id=b.subs_pts_id ';改成
where a.subs_pts_id=b.subs_pts_id
group by b.pts_typ_id
能帮我再改改吗
没有时用聚集函数的列 要放在group by 后面,
下面不知道是不是你要的结果select b.SUBS_PTS_ID,
b.CURRENT_PTS,
a.ACC_PTS,
a.SUBS_ID,
a.STATUS,
sum(decode(b.pts_typ_id,''消费'',''消费'',0)),
sum(decode(b.pts_typ_id,''在网'',''在网'',0)),
sum(decode(b.pts_typ_id,''奖励'',''奖励'',0)),
sum(decode(b.pts_typ_id,''信用'',''信用'',0))
from subs_points a, |
subs_typ_points b
where a.subs_pts_id=b.subs_pts_id
group by b.SUBS_PTS_ID,
b.CURRENT_PTS,
a.ACC_PTS,
a.SUBS_ID,
a.STATUS
总之,多谢!!
b.CURRENT_PTS,
a.ACC_PTS,
a.SUBS_ID,
a.STATUS
' select b.SUBS_PTS_ID, '||--1
' MAX(b.CURRENT_PTS), '||--2
' MAX(a.ACC_PTS), '||--3
' MAX(a.SUBS_ID), '||--4
' MAX(a.STATUS), '||--5
' sum(decode(b.pts_typ_id,''消费'',''消费'',0)), '||--6
' sum(decode(b.pts_typ_id,''在网'',''在网'',0)), '||--7
' sum(decode(b.pts_typ_id,''奖励'',''奖励'',0)), '||--8
' sum(decode(b.pts_typ_id,''信用'',''信用'',0)) '||--9
' from subs_points a, '||
' subs_typ_points b '||
' where a.subs_pts_id=b.subs_pts_id '||
' group by b.pts_typ_id '; from
' MAX(b.CURRENT_PTS), '||--2
' MAX(a.ACC_PTS), '||--3
' MAX(a.SUBS_ID), '||--4
' MAX(a.STATUS), '||--5
' sum(decode(b.pts_typ_id,''消费'',''消费'',0)), '||--6
' sum(decode(b.pts_typ_id,''在网'',''在网'',0)), '||--7
' sum(decode(b.pts_typ_id,''奖励'',''奖励'',0)), '||--8
' sum(decode(b.pts_typ_id,''信用'',''信用'',0)) '||--9
' from subs_points a, '||
' subs_typ_points b '||
' where a.subs_pts_id=b.subs_pts_id '||
' group by b.pts_typ_id '; from