database - How to find top 10 sum of each match? -


i mean if have several x , several y , match this:

x -[ w ]-> y 

with x , y related several w ( there can several w between same pairs (x,y) )

i want top ten x each y property sum(w.property)

if return

return y , sum(w.property) , x order sum(w.property) desc limit 10 

i 10 need every y,

is there way that?

match x -[ w ]-> y y, sum(w.property) total, x order total desc y, collect({sum: total, x: x})[0..10] values unwind values value return y, value.sum, value.x 

you can skip unwind , change second with return if you're ok returning array. bit more efficient because you're not repeating values of y on , over. if going change map structure array this:

collect([total, x])[0..10] 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -