Query with let

For each book in the bibliography, list the difference between the book's price and the average price.

<results> 
  {
   let $doc := doc("bib.xml")
   let $average := avg($doc//price)
   for $b in $doc/bib/book
     let $difference := $b/price - $average
     return
       <data>{ $b/title } is {$difference} more expensive than the average. </data>
  }    
</results>
  • := like Pascal, not = like C and Java


  • Previous | Next | Top | Cafe con Leche

    Copyright 2002-2004 Elliotte Rusty Harold
    elharo@metalab.unc.edu
    Last Modified November 17, 2003