csy3024-assignment-1/scripts/queries/query5.cyp

13 lines
401 B
Plaintext

//DIsplay the team that has the best scoring power
MATCH (t:Team)-[:PLAYED_IN {played: "Home"}]->(m:Match)
WITH t, sum(m.full_time_scores[0]) AS home_goals
MATCH (t)-[:PLAYED_IN {played: "Away"}]->(m:Match)
WITH t, home_goals, sum(m.full_time_scores[1]) AS away_goals
WITH t, home_goals + away_goals AS total_goals
ORDER BY total_goals DESC
RETURN t.name as best_scoring_power, total_goals
LIMIT 1