github.com/unigraph-dev/dgraph@v1.1.1-0.20200923154953-8b52b426f765/systest/21million/queries/query-046 (about)

     1  {
     2    PJ as var(func:allofterms(name@en, "Peter Jackson")) {
     3      director.film {
     4        starring {  # starring an actor
     5          performance.actor {
     6            movies as count(actor.film)  
     7            # number of roles for this actor
     8          }
     9          perf_total as sum(val(movies))       
    10        }
    11        movie_total as sum(val(perf_total))
    12        # total roles for all actors in this movie
    13      }
    14      gt as sum(val(movie_total))
    15    }
    16  
    17    PJmovies(func: uid(PJ)) {
    18      name@en
    19    	director.film (orderdesc: val(movie_total), first: 5) {
    20      	name@en
    21      	totalRoles : val(movie_total)
    22    	}
    23      grandTotal : val(gt)
    24    }
    25  }
    26  ---
    27  {
    28    "PJmovies": [
    29      {
    30        "director.film": [
    31          {
    32            "name@en": "The Lord of the Rings: The Two Towers",
    33            "totalRoles": 1565
    34          },
    35          {
    36            "name@en": "The Hobbit: The Desolation of Smaug",
    37            "totalRoles": 1261
    38          },
    39          {
    40            "name@en": "The Lord of the Rings: The Fellowship of the Ring",
    41            "totalRoles": 1335
    42          },
    43          {
    44            "name@en": "The Lord of the Rings: The Return of the King",
    45            "totalRoles": 1518
    46          },
    47          {
    48            "name@en": "The Hobbit: An Unexpected Journey",
    49            "totalRoles": 1274
    50          }
    51        ],
    52        "grandTotal": 10592,
    53        "name@en": "Peter Jackson"
    54      },
    55      {
    56        "name@en": "Sam Peter Jackson"
    57      },
    58      {
    59        "name@en": "Peter Jackson"
    60      },
    61      {
    62        "name@en": "Peter Jackson"
    63      },
    64      {
    65        "name@en": "Peter Jackson"
    66      }
    67    ]
    68  }