Gavin
Gavin

Reputation: 19

How to get a node's field and avg all of them in total?

My Schema

This is what I need my query to do: For classification "Sophomore", list the classification (Sophomore) and the average GPA of students with that classification.

This is what I have:

MATCH (user)<-[:Student]-(Student)
WHERE user.Classification = "Sophomore"
RETURN user.GPA as Student

Upvotes: 1

Views: 59

Answers (1)

William Lyon
William Lyon

Reputation: 8546

Looking at your schema it appears that you have all relevant properties (Classification and GPA) on the Student node label. If that's the case there's no need to traverse a relationship here. Try this query:

MATCH (s:Student) WHERE s.Classification = "Sophomore"
RETURN avg(s.GPA)

Upvotes: 1

Related Questions