diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-02-06 22:16:00 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-02-06 22:16:00 +0100 |
commit | bcf585b1cfba4354989c828a3ecb3168f3eae8b9 (patch) | |
tree | b3a2ecf0a88bec8a376505ab798ba511efa828c2 /Year_2/Databases | |
parent | 3c5a09ef620a9256fb3cf85d5d913fc2507515b0 (diff) |
databases: ex 3
Diffstat (limited to 'Year_2/Databases')
-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.xquery | 15 |
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> |