0

I am trying to execute the below query in a query activity. The intent is to find how many emails a customer record have. The query is executing without errors but the No_Of_Email column is not getting populated.

Could anyone see any obvious errors.

Thanks for your help on this.

 SELECT
 ((CASE WHEN email1_TXT ='' THEN 0  ELSE 1 END)+
(CASE WHEN email2_TXT ='' THEN 0  ELSE 1 END)+
(CASE WHEN email3_TXT ='' THEN 0  ELSE 1 END)) as No_Of_Email
   ,Customer_ID

FROM Customer
0

I have made few tweaks on the SQL and this should work. I do not have the same table/DE setup on my end but I am happy to go forward and debug further if this doesn't work for you.

SELECT 
(
    (CASE WHEN email1_TXT IS NULL THEN 0 ELSE 1 END)
    +
    (CASE WHEN email2_TXT IS NULL THEN 0 ELSE 1 END)
    +
    (CASE WHEN email3_TXT IS NULL THEN 0 ELSE 1 END)
) AS 'No_Of_Email', Customer_ID
FROM Customer
  • Thanks,Are you changing the ' ' to NULL,I couldn't see any other changes but wanted to check before we give this a try. – Monomit Bhowmik Aug 30 '18 at 1:18
  • Yes, I changed it to NULL as well the No_Of_Email with quotes. Let me know if this works – Brad Sapkota Aug 30 '18 at 2:38
0

We had found the solution to the issue-The data type was Number and it was not populating the count column ,when we changed the Data Type to Text the results started getting populated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.