TypeDBT
TypeDB3mo ago
6 replies
Joshua

Reducing with 0 when value is not there

question for the non-existent values:
when we sum over an attribute, say payment and for some records that this value is non-existent (which i believe typedb doesn't create any instance of that attribute for that particular entity?), how can i set 0 for those cases in my sum? I don't care about my entity just in my sum i want to replace n/e with 0.
here is a query, where $pa could be non-existent for some records:
match
$p isa payment_detail,
has loan_id $li,
has payment_amount $pa;
reduce $payments = sum($pa) groupby $li;
sort $li;

(originally from @Reza )
Was this page helpful?