Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-27-2020 11:12 AM
Hello Everyone,
I am new to NEO4j and trying to practice Cypher based on my Arrows tool design (Screenshot attached). I've successfully imported my CSV files to NEO4j. However, I am having a hard time returning my target output using Cypher. How should I query the questions below? It seems to be basic but when connecting relationships on my query I get stuck and it returns no data.. Any help would be really appreciated. Thanks in advance!!!!
I have tried for few hours but the output is nowhere close to my target output.. Thank you so much for your time and support.
Respectfully,
Petra Lee
Solved! Go to Solution.
06-29-2020 11:17 AM
Elena,
Thank you so much for your help!! you're amazing. This helped me to understand relationship between the nodes and my design better. Thanks again.
For the question #2, the screenshot was cut off a bit. My apologies!!
RegistrationDemograph and Event node both have property "evtUid" (integer).
RegistrationDemograph > Registration > Event all have "evtUid".
with Cypher, how to find which evtUid is connected the most from RegistrationDemograph node to Event node? I wanted to see the sorted list in descending order and it's giving me hard time. For some my output is empty all the time.. Thanks in advance and thank you for your time.
Respectfully,
Petra Lee
06-28-2020 10:50 PM
Hi Petra,
I will try to give you the correct cypher queries. However, without knowing your data and your failed queries, they might still not work. Just re-ask if there is something wrong.
MATCH (r:Registration)-[:belongs_to]->(e:Event)
WITH count(r) AS countRegistrations, e
RETURN e.evtName, countRegistrations
From your arrows sketch, there is no connection between a RegistrationDemograph node and an Event node. Should there be? Or can you elaborate on what exactly you want here?
Same as 1.
MATCH (r:Registration)-[:knows]->(rd:RegistrationDemograph)
WITH count(r) AS countRegistrations
SET rd.countRegistrations = countRegistrations
MATCH (rd:RegistrationDemograph)
WITH count(rd) AS numberRDs, sum(rd.countRegistrations) AS sumRegistrations
RETURN sumRegistrations/toFloat(numberRDs)
I hope I could help you.
Regards,
Elena
06-29-2020 11:17 AM
Elena,
Thank you so much for your help!! you're amazing. This helped me to understand relationship between the nodes and my design better. Thanks again.
For the question #2, the screenshot was cut off a bit. My apologies!!
RegistrationDemograph and Event node both have property "evtUid" (integer).
RegistrationDemograph > Registration > Event all have "evtUid".
with Cypher, how to find which evtUid is connected the most from RegistrationDemograph node to Event node? I wanted to see the sorted list in descending order and it's giving me hard time. For some my output is empty all the time.. Thanks in advance and thank you for your time.
Respectfully,
Petra Lee
06-29-2020 01:44 PM
Try this:
MATCH (rd:RegistrationDemograph)-[:belongs_to]->(r:Registration)-[:belongs_to]->(e:Event)
WHERE re.evtUid = r.evtUid = e.evtUid
RETURN distinct rd.demName as RegistrationDemograph, count(distnct e.evtUid) as TotEvents ORDER BY TotEvents DESC
06-29-2020 02:09 PM
ameyasoft,
Thank you so much for your help this query helped me to understand!! Special thanks to Elena as well. Thank you guys for the support and encouraging others. I hope to connect again in near future and have a great day everyone! Go NEO4j
All the sessions of the conference are now available online