1

I want all the distinct players (of a given team), the leagues they have played in without duplicate players ordered by the league start date. I've the below query return all the players (of a given team) and the leagues they participated in ordered by the start date but as you can see there are duplicates.

START t=node(17) 
MATCH player-[:PLAYED_WITH_TEAM]->t-[:CONTESTED_IN]->league 
RETURN player.name, league.startDate, league.name 
ORDER BY league.startDate, player.name

result of the above query

enter image description here

Here is my model

enter image description here

4

1 回答 1

2

解决方案的关键是collect函数的使用。由于您希望联赛按开始日期排序,您可能需要with将查询分成两部分:

START t=node(17) 
MATCH player-[:PLAYED_WITH_TEAM]->t-[:CONTESTED_IN]->league 
WITH player.name as playerName, league.startDate as startDate, league.name as leagueName 
ORDER BY startDate
RETURN player.name, collect(leagueName)

由于我没有可用的数据集,因此无法测试查询,因此请自行测试。

于 2013-06-06T20:14:19.807 回答