gpt4 book ai didi

docker - 如何在Cypher Neo4j中合并多个WITH和MATCH子句

转载 作者:行者123 更新时间:2023-12-02 18:28:01 25 4
gpt4 key购买 nike

我正在研究一个包含两个彼此相关的不同部分的问题。我想将两者结合起来。

1:第一部分

MATCH (r:Route)-[source_Airport_ID]->(a:Airport)
with count(r.SourceAirportID) as cnt, a.AirportID as
NumberofAirports_Having_source_flightGreater300
where cnt>300
Return Count(NumberofAirports_Having_source_flightGreater300)

2:第二部分
MATCH (r:Route)-[destination_Airport_ID]->(a:Airport) 
with count(r.SourceAirportID) as cnt, a.AirportID as
NmberofAirports_Having_destination_flightGreater300
where cnt>300
Return Count(NumberofAirports_Having_destination_flightGreater300)

3:合并部分
MATCH (r:Route)-[source_Airport_ID]->(a:Airport) 
with count(r.SourceAirportID) as cnt, a.AirportID as
NumberofAirports_Having_source_flightGreater300
where cnt>300

MATCH (r:Route)-[destination_Airport_ID]->(a:Airport)
with count(r.SourceAirportID) as cnt, a.AirportID as
NumberofAirports_Having_destination_flightGreater300,
NumberofAirports_Having_source_flightGreater300
where cnt>300

Return
Count(NumberofAirports_Having_source_flightGreater300),
Count(NumberofAirports_Having_destination_flightGreater300)

1:第一个给计数104

2:第二个查询也给出104

3:但是当我将两者结合时,答案是10816。如何将两者结合,并且答案仍然是104?

最佳答案

这应该工作:

MATCH (r:Route)-[source_Airport_ID]->(a:Airport)
with count(r.SourceAirportID) as cnt, a.AirportID as
NumberofAirports_Having_source_flightGreater300
where cnt>300
WITH COUNT(NumberofAirports_Having_source_flightGreater300) AS cnt1

MATCH (r:Route)-[destination_Airport_ID]->(a:Airport)
WITH cnt1, count(r.SourceAirportID) as cnt, a.AirportID as
NmberofAirports_Having_destination_flightGreater300
where cnt>300
Return cnt1, Count(NumberofAirports_Having_destination_flightGreater300) AS cnt2

关于docker - 如何在Cypher Neo4j中合并多个WITH和MATCH子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56603864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com