两种方式的数据集不同待解决
select sum(settle_pq)
from G_LL_STAT GLS, G_LINE_PQ GLP,G_LINE GL,O_ORG OO ,pub_e_pq_amt p
where GLS.ORG_NO like '43401'||'%'
AND GLS.BGN_DATE >= TO_DATE(to_char(sysdate,'YYYY')||'0101', 'YYYYMMDD')
AND GLS.BGN_DATE <= TO_DATE('201305' || '01', 'YYYYMMDD')
AND GLS.STAT_ID = GLP.STAT_ID
AND GL.LINE_ID = GLP.LINE_ID
AND GL.ORG_NO = OO.ORG_NO
and p.line_id(+)=gl.line_id
and p.prc_code != '00000000'
and p.rcvbl_amt_id > 0
GROUP BY (GL.LINE_ID)
HAVING(MAX(GL.LINE_ID) IS NOT NULL)
ORDER by GL.LINE_ID
----------------------------------------------------
select
(
select nvl(sum(p.settle_pq),0)
from pub_e_pq_amt p
where
p.prc_code != '00000000'
and p.rcvbl_amt_id > 0
and p.line_id=gl.line_id
) as 用户用电量
from G_LL_STAT GLS, G_LINE_PQ GLP,G_LINE GL,O_ORG OO
where GLS.ORG_NO like '43401'||'%'
AND GLS.BGN_DATE >= TO_DATE(to_char(sysdate,'YYYY')||'0101', 'YYYYMMDD')
AND GLS.BGN_DATE <= TO_DATE('201305' || '01', 'YYYYMMDD')
AND GLS.STAT_ID = GLP.STAT_ID
AND GL.LINE_ID = GLP.LINE_ID
AND GL.ORG_NO = OO.ORG_NO
GROUP BY (GL.LINE_ID)
HAVING(MAX(GL.LINE_ID) IS NOT NULL)
ORDER by GL.LINE_ID