cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to compare first Relationship to other Relationships with same type

Hi, I have following Schema below:


For easy to see, here is the structe:
CREATE (:Customer)-[:BUY {InvoiceId, UnitPrice}]->(:Product)
Customer can have many Invoice(:BUY relation ship), I want to find Which customers increased spending from the first purchase to the last?(Calculate depend on UnitPrice), I'm thinking first finding all (:BUY relationship) of Customers than sort date of those relatationships in Ascending order than get the first element as FirstBuy and then use avg() to calculate an average of UnitPrice of all (:BUY relationship) I call this as AverageBuying , then check AverageBuying and FirstBuy if FirstBuy greater than AverageBuying mean customer not pay greater after the first buy so I will remove that customer, is this best way? And so can somebody give me example how to implement this, I think this maybe a complex query I'm not sure can write correctly, thanks

0 REPLIES 0