go语句查询,起点 终点 一样 rank不一样 获得最新的一条数据

nebula 2.5 s studio 3.0
go from “player104” over serve bidirect yield $$.team.name,serve.start_year as start_year,serve.end_year | order by $-.start_year ;
如图示,会查询出两条Hornets,两条Spurs,如何根据时间区分,只取最新的一条,将现在的结果由10条返回成8条。

go语句是walk遍历,点和边都允许重复,你这个查询用go目前看没法解决你的只保留最新一条记录的问题。在studio中目前只能这样,如果在应用程序中,可以自己写应用逻辑过滤下

可以用 group by 做去重,然后返回 max(start_year)

(czp@nebula) [nba]> go from "Tim Duncan","Yao Ming","Tony Parker" over serve bidirect yield $$.team.name as team,serve.start_year as start_year
+-----------+------------+
| team      | start_year |
+-----------+------------+
| "Rockets" | 2002       |
+-----------+------------+
| "Spurs"   | 1997       |
+-----------+------------+
| "Hornets" | 2018       |
+-----------+------------+
| "Spurs"   | 1999       |
+-----------+------------+
Got 4 rows (time spent 4712/5230 us)

Thu, 16 Sep 2021 18:01:29 CST

(czp@nebula) [nba]> go from "Tim Duncan","Yao Ming","Tony Parker" over serve bidirect yield $$.team.name as team,serve.start_year as start_year | yield $-.team,max($-.start_year)
+-----------+--------------------+
| $-.team   | max($-.start_year) |
+-----------+--------------------+
| "Hornets" | 2018               |
+-----------+--------------------+
| "Rockets" | 2002               |
+-----------+--------------------+
| "Spurs"   | 1999               |
+-----------+--------------------+
Got 3 rows (time spent 4072/4473 us)


浙ICP备20010487号