当前位置:网站首页>click house Code: 47, e.displayText() = DB::Exception: Missing columns:

click house Code: 47, e.displayText() = DB::Exception: Missing columns:

2020-12-07 08:47:20 osc_ s7aj86hu

Saturday , Get up at ten in the morning , After all, I've been working for a week , Occasionally steal a little lazy !

Get into the business !

---- notes ---/* It's just a name I casually wrote , Look down */--------
select 
    case when b.val is null then a.val
           when b.val <= 0   then a.val 
    else a.val / a.qty  
    end  as RTL_VAL  
from  surface 1 a 
left join  surface 2 b 
on a.id = b.id 

My need is , When b.val by null perhaps <= 0 when , I want to use a.val , Otherwise, it's a division operation

Here I use CK(clickhouse) When you do the calculation , He would suggest that the divisor cannot be 0

Then calculate separately Conduct union all

select 
    divide(a.val,b.CONVERTER) as RTL_VAL   
 from a 
left join b on a.id = b.id
where b.val >0 and b.val is not null
union all 
select
   a.val as RTL_VAL
 from a 
left join b on a.id = b.id
where b.val <=0  and b.val is not null 


--- notes :divide  It's the quotient of numbers . The result type is always floating point type .  It's not integer division . For integer division , Please use 'intDiv' function .  When divided by zero , You get 'inf','- inf' or 'null'---

When you're doing an operation , You'll find out or wrong !

Here's another database Conduct union all Look at the fields I've framed !( These are actually intercepted by me , ha-ha , But it does not affect the operation !)

Now? , I must be wondering , Dig two grass SQL Can run calculations , Why? union all Will report a mistake ?

remember ! Focus on ! The exam will take place !

CK For the moment , It should not support union all The lower one  as Alias !

After removing the alias , You can calculate ! The other thing is that

Your field must follow   The corresponding above !

  Be sure to match !

Be sure to match well ! 

Otherwise, it will be wrong ! The specific report is wrong I forgot .  

From ten to six in the afternoon , I met such a pit !  It's the sun .

I hope it will help you . Bye-bye ~  Eating out .

版权声明
本文为[osc_ s7aj86hu]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201207084222541c.html