i surprised results of query , hoping can explain it.
the query kind of large, distilled key part:
select * inner join b on a.id = b.id left join c on c.id = b.id a.dt = '2016-06-23' , (b.statuscode=' ' or c.code <> 9)
i getting dates other 6/23/16 though have in clause. think has combining columns in clause left joined table , inner joined table in 1 expression, have never experienced before.
update: adding actual query
select * cert2.cube_mbbal_daily_balances bal inner join cert.dim_account on a.accountkey = bal.accountkey left join cert2.dim_loanaccount la on a.accountkey = la.accountkey (a.accountclassification in ('checking', 'savings') , accountstatus in ('1', '3', '5', '6', '7')) or (a.accountclassification in ('time') , accountstatus in ('1', '5', '7')) or (a.accountclassification in ('loan') , (accountstatus <> 'c' or riskcode <> 9)) , bal.dateoffinancialmeasure = 20160623
and
evaluated before or
. it's you're evaluating 2 + 5 + 7 * 5
, wondering why you're getting 42
, not 70
.
try:
select * cert2.cube_mbbal_daily_balances bal inner join cert.dim_account on a.accountkey = bal.accountkey left join cert2.dim_loanaccount la on a.accountkey = la.accountkey ( (a.accountclassification in ('checking', 'savings') , accountstatus in ('1', '3', '5', '6', '7')) or (a.accountclassification in ('time') , accountstatus in ('1', '5', '7')) or (a.accountclassification in ('loan') , (accountstatus <> 'c' or riskcode <> 9)) ) , bal.dateoffinancialmeasure = 20160623
Comments
Post a Comment