标签云

微信群

扫码加入我们

WeChat QR Code

Imagine I have a graph which I query like this: MATCH (n:Class)-[:HAS]->(i:Item)RETURN n.id as Id1, i.id as IdI, i.isWhatever as CriteriongettingIdC IdICriterion A 1FalseA 2 TrueB 1 TrueMy desired output would beIdC ratioCriterion A0.5B1I guess this question boils down to how can I sum a list of booleans in cypher. The part of dividing by the size of the aggregation is easy. I mean that the complete query would look like:MATCH (n:Class)-[:HAS]->(i:Item)WITH n.id as Id1, count_number_of_True_values / count(*) as ratioCriterionBut I just don't know how to write the count_number_of_True_values bit.


Thanks a lot. I guess that for readability I would just remove the second line and write the second like this: WITH n.id as Id1, CASE WHEN i.isWhateverTHEN 1 ELSE 0 END AS numCrit.

2019年07月24日48分19秒