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

12 lines
459 B
Plaintext

//Display the team that has the worst defending
MATCH (t:Team)-[:PLAYED_IN {played: "Home"}]->(m:Match)
WITH t, sum(m.full_time_scores[1]) AS home_conceded_goals
MATCH (t)-[:PLAYED_IN {played: "Away"}]->(m:Match)
WITH t, home_conceded_goals, sum(m.full_time_scores[0]) AS away_conceded_goals
WITH t, home_conceded_goals + away_conceded_goals AS total_conceded_goals
ORDER BY total_conceded_goals DESC
RETURN t.name AS worst_defending, total_conceded_goals