summaryrefslogtreecommitdiff
path: root/Year_2/Databases/libri_ex2.xquery
diff options
context:
space:
mode:
Diffstat (limited to 'Year_2/Databases/libri_ex2.xquery')
-rw-r--r--Year_2/Databases/libri_ex2.xquery9
1 files changed, 9 insertions, 0 deletions
diff --git a/Year_2/Databases/libri_ex2.xquery b/Year_2/Databases/libri_ex2.xquery
new file mode 100644
index 0000000..e20b41f
--- /dev/null
+++ b/Year_2/Databases/libri_ex2.xquery
@@ -0,0 +1,9 @@
+let $f := doc("libri.xml")
+let $authors := $f//autore
+
+for $author in distinct-values($authors)
+let $books := $f//libro[autore=$author]
+return <author>
+ <name>{ $author }</name>
+ <num>{ count($books) }</num>
+ </author>