I need to do the case when on the nested table. The table is looked like this:
I want to take each customerId and the counts of their completed referral. The completed referral rules is, when isActive Yes, balanceFullfilment Yes, and disbursmentStatus Yes.
The output may look like this:
+------------------------------+-------------------------+
| CustomerId | completedReferrals |
+------------------------------+-------------------------+
| 5ee3069303e3ba522d200ecf | 0 |
| 0330633746 | 1 |
| 5ecf73d14dc2ad166325a447 | 0 |
| 5f0ece768b16a2aa59ab31f3 | 0 |
+------------------------------+-------------------------+
I think this is similliar to
SELECT SUM(CASE WHEN isActive = 'Yes' and balanceFullfillment = 'Yes' and disbursementStatus = 'Yes' then 1 else 0)
But I don't know how to perform it on nested table, can someone help?
