summaryrefslogtreecommitdiff
path: root/Year_2
diff options
context:
space:
mode:
Diffstat (limited to 'Year_2')
-rw-r--r--Year_2/Databases/university_marks_ex2.xquery (renamed from Year_2/Databases/university_marks.xquery)5
-rw-r--r--Year_2/Databases/university_marks_ex3.xquery15
2 files changed, 18 insertions, 2 deletions
diff --git a/Year_2/Databases/university_marks.xquery b/Year_2/Databases/university_marks_ex2.xquery
index e2f0e4e..e75616c 100644
--- a/Year_2/Databases/university_marks.xquery
+++ b/Year_2/Databases/university_marks_ex2.xquery
@@ -1,4 +1,4 @@
-<students>
+<ex2>
{
for $student in doc("university_marks.xml")//libretto
where $student/esami//voto/text()=30
@@ -8,4 +8,5 @@ return <student>
{$student/studente/cognome/text()}
</student>
}
-</students>
+</ex2>
+
diff --git a/Year_2/Databases/university_marks_ex3.xquery b/Year_2/Databases/university_marks_ex3.xquery
new file mode 100644
index 0000000..dd1f5b8
--- /dev/null
+++ b/Year_2/Databases/university_marks_ex3.xquery
@@ -0,0 +1,15 @@
+<ex3>
+{
+let $f := doc("university_marks.xml")
+let $courses := distinct-values($f//materia)
+
+for $course in $courses
+return <course area="{$course}">
+ {
+ for $data in $f//libretto
+ where $data//esami//esame//materia/text()=$course
+ return <student>{$data//studente/@matricola}</student>
+ }
+ </course>
+}
+</ex3>