几天来,我一直在努力获得以下结果:
我有这个数据集:
e1 = g.addV('company').property('name', 'company-1').next()
e2 = g.addV('company').property('name', 'company-2').next()
p1 = g.addV('product').property('name', 'product-1').next()
p2 = g.addV('product').property('name', 'product-2').next()
p3 = g.addV('product').property('name', 'product-3').next()
i1 = g.addV('tax').property('name', 'tax-1').next()
i2 = g.addV('tax').property('name', 'tax-2').next()
g.addE('taxes').from(i1).to(p1).property('amount', 10)
g.addE('taxes').from(i2).to(p2).property('amount', 15)
g.addE('taxes').from(i1).to(p3).property('amount', 20)
g.addE('taxes').from(i2).to(p3).property('amount', 20)
g.addE('sells').from(e1).to(p1).property('price', 10)
g.addE('sells').from(e1).to(p2).property('price', 15)
g.addE('sells').from(e2).to(p2).property('price', 20)
g.addE('sells').from(e2).to(p3).property('price', 25)我需要对一家公司销售的所有产品进行汇总(公司-1= 25,公司-2= 45 )。目前,我陷入了以下查询:
g.V().hasLabel('company').as('e').outE('sells').as('f').inV().as('p').inE('taxes').as('i').outV().select('e', 'p', 'f', 'i').by('name').by('name').by('price').by('amount').group().by('e')关于我如何做到这一点有什么建议吗?此外,如果有人能给我一个例子,说明我如何计算金额,但考虑到税收,比如: value = product * (1 + (amount/100))
发布于 2020-06-26 22:07:46
我认为这给你提供了你所需要的,首先按公司分组,然后把边缘的价格相加:
g.V().hasLabel('company').as('e').
outE('sells').as('f').
group().
by(select('e').values('name')).
by(values('price').sum())https://stackoverflow.com/questions/62603148
复制相似问题