-1

I am trying to display three different variables at once. Here is what i have tried.

         let $totalmovies := count(//Movies/Movie)
         let $averagevariton:=(count(//Movies/Movie/secondtitles/OtherTitleName) + count(//Movies/Movie/Title) ) div $totalmovies

         for $m in //Movies/Movie
         let $year := (max($m/secondtitles/Year) - min($m/secondtitles/Year))+1

         order by $year descending

         return ($totalmovies,$averagevariton,$year)

But at the moment, it keeps printing the values until for loop is done. How can I display those values only once?

user2775042
  • 509
  • 2
  • 6
  • 21

1 Answers1

0

It isn't clear what the correct output should be, maybe you want to use for loop only to populate the $year variable, something like this :

let $totalmovies := count(//Movies/Movie)
let $averagevariton:= (count(//Movies/Movie/secondtitles/OtherTitleName) + count(//Movies/Movie/Title) ) div $totalmovies
let $year := 
    for $m in //Movies/Movie
    let $diff := (max($m/secondtitles/Year) - min($m/secondtitles/Year))+1
    order by $diff descending
    return $diff
return ($totalmovies,$averagevariton,$year)
har07
  • 88,338
  • 12
  • 84
  • 137