AnsweredAssumed Answered

Execute SQL with alias column names

Question asked by smalltalker on Aug 16, 2018

Hi, quick question regarding Execute SQL. My query contains an additional verification from the same column, so I'm using alias name:

 

select (some columns),

case when ad1.address IS NULL

then ad4.address 
else ad1.address
end adress,
case when ad1.address IS NULL then ad4.zip
else ad1.zip
end zip

from customer cu
left outer join address ad1 on cu_number = ad1.customer and ad1.type = 1 and ad1.expire_date is null
left outer join address ad4 on cu_number = ad4.customer and ad4.type = 4 and ad4.expire_date is null

where = (item property)

group by (all related columns from the select)

 

For each column, I'm storing the outcome with different collection operations (Collection variable to Text variable) on the same index, but the workflow returns the following error: "Error operating on collection variable. Index property is greater than the number of items in the collection."

 

The SQL works perfectly without the extra alias (ad4) so I'm guessing it has something to do with it. I have tried different solutions without any luck. How do a beginner like me solve this issue?

 

Br,

Asbjørn Nielsen

Outcomes