Use OF LET with CASE in N1QL

Hi,

I have two queries one with CASE IN LET KEYWORD AND one without.
Below query works fine

select ARRAY 'https://xyz.com/mmi-uat-exploreimages/pin/'||type||'/original/' || v.photo FOR v WITHIN images END AS 
pictures from pins LET type = pin_type WHERE pin_type ='atlas';

But When I use CASE in let statement query fails

select ARRAY 'https://xyz.com/mmi-uat-exploreimages/pin/'||type||'/original/' || v.photo FOR v WITHIN images END AS 
pictures from pins LET type = CASE WHEN pin_type='atlas' THEN 'checkin' ELSE pin_type END AS test WHERE pin_type ='atlas';

with following errors

[
  {
     "code": 3000,
     "msg": "syntax error - at AS",
     "query_from_user": "select ARRAY 'https://s3.ap-south-1.amazonaws.com/mmi-uat-exploreimages/pin/'||type||'/original/' || v.photo FOR v WITHIN images END AS \npictures from pins LET type = CASE WHEN pin_type='atlas' THEN 'checkin' ELSE pin_type END AS test WHERE pin_type ='atlas';"
   }
 ]

You have extra AS test at the end of LET.
You can assign let variable not Alaias

1 Like