(: Print distinct authors and the books they wrote, sorted alphabetically :) for $book in db:open("books")//book let $title := $book/title/text() group by $author := $book/author/text() return {$author} {count($title)} {for $t in $title order by $t ascending return {$t}}