Parseexception kw_end missing near 'as'

1.7k Views Asked by At

I am getting parseexception kw_end missing near 'as' error for the below query :

Case 
when x=y then 
  case when g<h then 2 else 0 end
When x=z then 
  case when i>k then 6 else 0 end 
else 
  case when v=s then 3 else 0 end 
end as 'block';

Here i am not getting what's going wrong.... What's the mistake here to get the above error?

1

There are 1 best solutions below

0
Koushik Roy On

Please use backtick (`) around alias name. Single quote(') can act like a string identifier and may not behave properly.

Case 
when x=y then 
  case when g<h then 2 else 0 end
When x=z then 
  case when i>k then 6 else 0 end 
else 
  case when v=s then 3 else 0 end 
end as `block` --backtick enclosed alias