Query with let

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

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

  • Previous | Next | Top | Cafe con Leche

    Copyright 2002-2004 Elliotte Rusty Harold
    Last Modified November 17, 2003