Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
RAJ6
Contributor III
Contributor III

I need to convert the below SQL case statement into if\else for talend

Hi Talend Folks,

i need your help. could you please tell me. how to convert the below SQL case statement into if\else using tmap components for talend.

 

(case
when
(case
when t1.Sales = 'others' and t2.Bundled = 'Bundled'
then 'Bundled'
else t1.Sales end) = 'others'
then 'Discounted'

else
(case
when t1.Sales = 'others' and t2.Bundled = 'Bundled'
then 'Bundled'
else t1.Sales end)
end) AS Bundle

Labels (2)
7 Replies
TRF
Champion II
Champion II

Can you share the flow schema?

Is only 1 flow or 2?

Also give a sample input data with expected result.

RAJ6
Contributor III
Contributor III
Author

My source is excel file. I have sql logic. i need to create same sql expression in talend using tmap.

Sales Excel and drop it to the design work space and select tfileInputExcel option from pop window then am using tmap component. I dragged all columns into output excel file side then I Just created new column as bundled then I wrote if \ else Statement. the logic is given below

 

((row8.Sales == "others" && row9.Bundled== "Bundled") ? "Bundled" : ((row8.Sales) == "others" ? "Discounted" :

((row8.Sales == "others" && row9.Bundled== "Bundled") ? "Bundled" :

((row8.Sales)))))

 

Above logic is not working. am getting error 

TRF
Champion II
Champion II

1st, don't use "==" to compare strings, use String.equals method or String.equalsIgnoreCase instead giving:

"others".equals(row8.Sales)

and so on.

2nd, rethink the logic, you have twice the same test (row8.Sales == "others" && row9.Bundled == "Bundled") which cannot occurs.

 

med1
Creator
Creator

Hello,

 

You can use condition statement in tMap :

 

row1.myKey.equals("FirstValue")?1:0

 

which allow you to do your query in the variable window and get the result in the tMap output.

 

Thanks,

Med

genupula
Contributor
Contributor

Hi  All,

 

   i need to convert the below case statement in talend

 

CASE WHEN mcw_qualitypot_prod_event_deduped.qualitypot_prod_task_type  ="IMAGE_REVIEW"
AND mcw_qualitypot_prod_event_deduped.qualitypot_prod_error :: text ='incorrectRejected'
THEN count(
mcw_qualitypot_prod_event_deduped.qualitypot_prod_error
) ELSE NULL END AS quality_incorrectrejectedpots,

 

please provide solution for the above requirement

TRF
Champion II
Champion II

@Shekar_genupula if the answer in this post is not sufficient for your case, open a new post.