By using AWS re:Post, you agree to the Terms of Use

I'm trying to find a way to convert two booleans into a case when expression


The question is: how can i use two statements in a case when? I'm trying to find a way to make this select statement work. I'm writing code to see if there is contactinformation in a specific code (A01). A filter in the where clausule isn't enough because it's a joint source, I get too many results.

SELECT , (CASE WHEN ("concat"("abs"."waarneming_waarnsrt_code", "abs"."waarneming_waarnsrtreden_code") = ('A01') AND ("abs"."contact_contactsrtcode_telnr_telnrsms_emailadres" like '%@%') then 'email/telefoon in voormelding' end) emailtelefoon , (CASE WHEN ("concat"("abs"."waarneming_waarnsrt_code", "abs"."waarneming_waarnsrtreden_code") = ('A01') AND ("abs"."contact_contactsrtcode_telnr_telnrsms_emailadres" like '!%@%') then 'geen email/telefoon in voormelding' end) emailtelefoon

FROM "abs" INNER JOIN "c"nrs" "nrs" ON ("nrs"."barcd" = "abs"."barcd")

WHERE (("concat"("abs"."waarneming_waarnsrt_code", "abs"."waarneming_waarnsrtreden_code") = ('A01')) AND ("nrs"."year" = '2022') AND ("nrs"."collodata_product_productoptie_kenmsrtcode_optiesrtcode" LIKE '%021;020%') AND ("concat"("nrs"."waarneming_waarnsrt_code", "nrs"."waarneming_waarnsrtreden_code") = ('J23')) AND "week"("nrs"."waarneming_waarndt") > 17)

Group by 1,2 ORDER BY 1 ASC ;

asked 15 days ago24 views
1 Answer
Accepted Answer

As far as I understood, your requirement is to use more than one condition in case when. I have tested on my account and I was able to observe that we can use multiple boolean statements with CASE WHEN. Therefore, as far as I know, the query that you mentioned must be working fine without any troubles. I would like to know more details about your issue. Is it that the query is failing with any error? If yes, please share the error message. Else, what boolean statements you would like to convert into CASE WHEN?

These links - might probably be helpful:

If you require in depth analysis and help with respect to this issue then I would suggest you to raise a support case with AWS premium support team.

profile picture
answered 14 days ago
reviewed 14 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions