G
gaofei18
Unregistered / Unconfirmed
GUEST, unregistred user!
那位高手给看看:sql 外连接查询出的记录多了六倍?为什么?
select * from
(select
dwbm,a.dwmc,a.jjlxdm,b.grbh,b.name,b.sfzh,decode(xbdm,'1','
D','2',' ') xb,cssj,cjgzsj,txsj,ljjfnx,
decode(jyztdm||txztdm,'21__','1','2200','2','23__','3','2210','
4','2211','5','2212','5','2213','5','2211','5','2214','5'
,'2215','5','2216','5','2209','6','2203','7','3121','8','3122',
'9') ltlb,decode(grsfdm||txztdm,'11','1','12','2','21','6'
,'90','6','22','5','3_','4','__01','3')
grsf,xzzwdm,decode(ZYJSZWDM,'1','1','2','2','3','3')
zc,dqlbdm,c.qndqdm,
decode(txztdm,'02','1','__','2')
bwgg,nvl(d.lxj,0),nvl(d.txj,0),nvl(d.TZJ,0),nvl(d.hjje,0),nvl(d
.jcj,0),nvl(d.zhj,0),
nvl(d.gdj,0),nvl((d.tjj+d.dyc38),0)
tjj,nvl(d.JBTHJ,0),nvl(d.ysf,0),nvl(e.bfhj,0),nvl(d.dytzhj,0),n
vl(j.bfhj,0),
nvl(e.ZFBZ,0),nvl(e.qnf,0),decode(tfyydm,'1','2','2','2','3','1
','5','5') tfyy,j.jjgsq,j.bfhj,h.tfsj
from yw_da_dwjbxx a,
yw_da_ryjbxx b ,
yw_da_txzgxx c,
yw_sw_yljjfxx d,
yw_sw_bfmx e ,
yw_dm_jjlx f,
yw_cs_qnfbz g,
(select grbh,max(tfsj) tfsj from yw_da_tfxfxx group by grbh)
h,
(select grbh,sum(nvl(bfhj,0)) bfhj,jjgsq from yw_sw_bfmx
where jjgsq='2007-06-15' and bblx<>'2' and bblx<>'1' group by
grbh,jjgsq ) j
where a.dwnm=b.dwnm
and b.grbh=c.grbh
and c.grbh=d.grbh
and d.grbh=e.grbh
and b.grbh=j.grbh(+)
and a.jjlxdm=f.jjlxdm(+)
and c.qndqdm=g.qndqdm(+)
and b.grbh=h.grbh(+)
and e.jjgsq='2007-06-15'
and (e.bblx='1')
and a.dwnm='10003000994'
and b.jyztdm>'2'
and g.bxjgdm='003'
) x,
(select grbh,bfhj from yw_sw_bfmx where jjgsq='2007-06-15' and
bblx='2') y
where x.grbh=y.grbh(+)
select * from
(select
dwbm,a.dwmc,a.jjlxdm,b.grbh,b.name,b.sfzh,decode(xbdm,'1','
D','2',' ') xb,cssj,cjgzsj,txsj,ljjfnx,
decode(jyztdm||txztdm,'21__','1','2200','2','23__','3','2210','
4','2211','5','2212','5','2213','5','2211','5','2214','5'
,'2215','5','2216','5','2209','6','2203','7','3121','8','3122',
'9') ltlb,decode(grsfdm||txztdm,'11','1','12','2','21','6'
,'90','6','22','5','3_','4','__01','3')
grsf,xzzwdm,decode(ZYJSZWDM,'1','1','2','2','3','3')
zc,dqlbdm,c.qndqdm,
decode(txztdm,'02','1','__','2')
bwgg,nvl(d.lxj,0),nvl(d.txj,0),nvl(d.TZJ,0),nvl(d.hjje,0),nvl(d
.jcj,0),nvl(d.zhj,0),
nvl(d.gdj,0),nvl((d.tjj+d.dyc38),0)
tjj,nvl(d.JBTHJ,0),nvl(d.ysf,0),nvl(e.bfhj,0),nvl(d.dytzhj,0),n
vl(j.bfhj,0),
nvl(e.ZFBZ,0),nvl(e.qnf,0),decode(tfyydm,'1','2','2','2','3','1
','5','5') tfyy,j.jjgsq,j.bfhj,h.tfsj
from yw_da_dwjbxx a,
yw_da_ryjbxx b ,
yw_da_txzgxx c,
yw_sw_yljjfxx d,
yw_sw_bfmx e ,
yw_dm_jjlx f,
yw_cs_qnfbz g,
(select grbh,max(tfsj) tfsj from yw_da_tfxfxx group by grbh)
h,
(select grbh,sum(nvl(bfhj,0)) bfhj,jjgsq from yw_sw_bfmx
where jjgsq='2007-06-15' and bblx<>'2' and bblx<>'1' group by
grbh,jjgsq ) j
where a.dwnm=b.dwnm
and b.grbh=c.grbh
and c.grbh=d.grbh
and d.grbh=e.grbh
and b.grbh=j.grbh(+)
and a.jjlxdm=f.jjlxdm(+)
and c.qndqdm=g.qndqdm(+)
and b.grbh=h.grbh(+)
and e.jjgsq='2007-06-15'
and (e.bblx='1')
and a.dwnm='10003000994'
and b.jyztdm>'2'
and g.bxjgdm='003'
) x,
(select grbh,bfhj from yw_sw_bfmx where jjgsq='2007-06-15' and
bblx='2') y
where x.grbh=y.grbh(+)