q6qgs
(q511t)
March 6, 2020, 1:28am
1
Hi,
Based on my example below, i wanted to return list of user stories (US1 and US2) ordered by the number of tickets related to it that is also linked SP1. In other words, find me userstories (starting) with greatest number of tickets linked to SP1.
this is query I've got right now:
MATCH (:Sprint{id:"SP1"})<-[:SPRINT_TASK]-(:Ticket)-[:SUB_TASK]->(rec:UserStory)
WITH rec, COUNT(*) AS num ORDER BY num DESC
RETURN rec
Any help will is greatly appreciated :)
MATCH (:Sprint{id:"SP1"})<-[:SPRINT_TASK]-(:Ticket)-[:SUB_TASK]->(rec:UserStory)
WITH rec, COUNT(*) AS num ORDER BY num DESC
RETURN rec, num
This will return two nodes US1
and US2
. If you click "Table" button on the left side of the output, you will get what you want.
If you don't like this, try below
If you have declared your node as (:UserStory{ name : "US1" })
,try
MATCH (:Sprint{id:"SP1"})<-[:SPRINT_TASK]-(:Ticket)-[:SUB_TASK]->(rec:UserStory)
WITH rec, COUNT(*) AS num ORDER BY num DESC
RETURN rec.name,num
Hope this helps you.
1 Like
Try this
MATCH (:Sprint{id:"SP1"})<-[:SPRINT_TASK]-(:Ticket)-[r1:SUB_TASK]->(rec:UserStory)
WITH rec, COUNT(r1) AS num ORDER BY num DESC
RETURN rec,num
1 Like