永发信息网

oracle 左连接的时候结果集的数据条数少了,左表里有26574 ,左连接后就只有26522条数据了,sql 语句如下:

答案:2  悬赏:70  手机版
解决时间 2021-03-04 05:15
  • 提问者网友:自食苦果
  • 2021-03-03 12:53
select sum(a.sum),psn.psncode
from (
select pc.doccode xmcode,pc.docname xmname,a.cquarter,a.cperiod,a.cyear as cyear,
a.pk_corp,a.psnid,pl.psnclassname,pl.psnclasscode,dc.unitshortname,
nvl(sum(a.SUM/pc.shortname),0) as sum
from
(
select doccode , docname , memo, shortname
from bqdw_bd_psncost
where doccode in ('03' ,'04' ,'05' ,'06' ,'07' ,'08' )
) pc
left join
(
select * from BQDW_PSNCOST29 cost where cost.xmcode in ('03' ,'04' ,'05' ,'06' ,'07' ,'08' )
) a
on a.xmcode=pc.doccode
left join bqdw_bd_psncl pl on pl.pk_psncl=a.psnclid
left join bqdw_corp dc on dc.pk_corp=a.pk_corp
where pl.psnclasscode in ('0001','0002','0003','0004','0005') and a.cperiod='06' and doccode='03'
group by a.cyear,a.pk_corp,pc.doccode,pc.docname,a.cquarter,a.psnid,pl.psnclassname,pl.psnclasscode,dc.unitshortname,a.cperiod
) a left outer join bqdw_bd_psndoc_01 psn on a.psnid=psn.pk_psndoc
group by psn.psncode
最佳答案
  • 五星知识达人网友:山有枢
  • 2021-03-03 13:47
问题在于你最后用了group by
全部回答
  • 1楼网友:愁杀梦里人
  • 2021-03-03 14:19
where rownum < 3
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯