I am working on a question consist of two different parts related to each other. I want to combine both of them.
1: First Part
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: Second Part
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: Combine Part
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: First one gives count 104
2: Second query also gives 104
3: But when I combine both of them answer is 10816. How to combine both and the answer still remain 104 for both?
This should work:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With