Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

select as with cases and like

I need to implement the following PostgreSQL query by means of Talend:

select *, (case
when product_reviews.product not like '%[^0-9]%' then cast(product_reviews.product as varchar)
when product_reviews.product like '%@%' then cast((select product_details.product_code from product_details where lower(product_reviews.product) = lower(product_details.product_ID)) as varchar)
else cast((select product_details.product_code from product_details where lower(product_reviews.product) = lower(product_reviews.product_name)) as varchar)
end) as product_code;
from product_reviews;

Labels (4)
1 Reply
vapukov
Master II
Master II

Hi,

 

what is your question (problem) exactly?

btw, at least one error there:

select 
     XXXX,
     XXXX) as product_code;
from product_reviews;

you have wrong ; after as product_code

 

cheers