Cypher / neo4j: sum by value and generate grand total -
here's sample db: http://console.neo4j.org/r/plb1ez
it contains 2 categories name "digital cameras" query, grouping them name , homecoming significance*view_count each of category names: match a a.metatype = "category" homecoming distinct a.categoryname, sum(a.significance * a.view_count) popularity
however, need not absolute popularity (=significance*view_count), relative 1 - need query additionally homecoming sum of popularities (should 1500 according math), can calculate fraction (which phone call "relativepopularity") each category (popularity/grandtotal).
desired result: | d.categoryname | popularity | grandtotal | relativepopularity | | digital compacts | 300 | 1500 | 0.2 | | hand-held camcorders | 300 | 1500 | 0.2 | | digital slr | 150 | 1500 | 0.1 | | digital cameras | 750 | 1500 | 0.5 | +----------------------+------------+------------+--------------------+
currently i'm doing calculation 2 ansynchronous jobs, need done in 1 go.
thanks help!
neo4j cypher
No comments:
Post a Comment