Dgraph DQL Tour

Var Blocks

Exercise : Value variables - sum and avg

Summation sum and average avg can only be applied to value variables that contain int and float data.

Find which is greater, the number of movies by Steven Spielberg or the average number of actors in movies directed by him.

This query can be done in a single block, but you’ll see here how values are available in other blocks if the corresponding UID’s are available for the value map.

Spoiler alert:

After you have the query working, try changing the second block to use the wrong UID’s and see what happens. For example, change avs to query for a different director instead of using ID - the definition of variable ID would also need to be removed, otherwise it would be defined but not used.

5.8 Exercise : Value variables - sum and avg