-
sgg 小试身手Lv3
发表于2020-4-14 00:36
悬赏10
已解决
楼主
在“数据集”和“数据分析”建2张独立表的关联关系,计算的数据不对。如果用SQL主题表或ETL的SQL表输入或SQL数据源等的方式建成1张左连接表,计算的结果都是对的。请问问题出在哪里了,请大神支招,谢谢!
最佳答案
17个回答
wut 发表于 2020-4-14 07:19
对比下两种方式表关联程度生成的sql,有什么区别
关联关系里面只设置了一个左连接,计算出的SQL里面怎么多了一个右连接?
还是分析表设计有问题?,如下:
缱绻 发表于 2020-4-14 09:31
看下结果表生成的sql哪里有问题
1、SQL语句直接写的,计算的分析表数据是对的:
select IYI001,IYI002,IYI012,IYI902,IYI007,IYI008,IYI011,DAA002,IYI014,IYI015,IYK002,IYK003,DKB002,IYK004,IYK960,YJDZ,YJGZ,IYK005
from F_JYYJ
left JOIN F_YJZB ON F_JYYJ.IYI007 =F_YJZB.PHid and F_JYYJ.IYK003=F_YJZB.JYid
where IYI011 LIKE '07%' AND IYI015='T' AND IYI002>='20200401'
2、2张独立表,用表关联关系左联接后,计算的数据不对,运行的SQL如下:
select * from ( select a.A2 as A2,a.B2 as B2,a.C2 as C2,a.D2 as D2,a.E2 as E2,a.I2 as I2,b.F2 as F2,b.G2 as G2,a.J2 as J2
from (
select a.IYI012 as A2,a.DAA002 as B2,a.IYI008 as C2,a.DKB002 as D2,a.IYK960 as E2,a.IYK004 as I2,a.IYI001 as J2
from f_jyyj a
where ((a.IYI011 LIKE '0703%') AND (a.IYI015 = 'T') AND (a.IYI002 >= '20200401'))) a
inner join (
select a.YJDZ as F2,a.YJGZ as G2,b.IYI001 as J2
from f_yjzb a
left join f_jyyj b
on ((b.IYI007 = a.PHid) AND (b.IYK003 = a.JYid))
where ((b.IYI011 LIKE '0703%') AND (b.IYI015 = 'T') AND (b.IYI002 >= '20200401'))) b
on (a.J2=b.J2)
order by a.J2 desc ) as temp_ limit 1000
对应的表样如下:
sgg 发表于 2020-4-14 09:39
1、SQL语句直接写的,计算的分析表数据是对的:
select IYI001,IYI002,IYI012,IYI902,IYI007,IYI008,IYI0 ...
F_JYYJ.IYK003=F_YJZB.JYid 除了左连接还需要有个内连接把