This commit is contained in:
Imbus 2024-01-25 19:40:23 +01:00
parent d316a660cd
commit 3dd7d1c576
15 changed files with 51 additions and 1 deletions

2
a.sql Normal file
View file

@ -0,0 +1,2 @@
select firstName, lastName
from Students

3
b.sql Normal file
View file

@ -0,0 +1,3 @@
select firstName, lastName
from Students
order by lastName, firstName

3
c.sql Normal file
View file

@ -0,0 +1,3 @@
select firstName, lastName
from Students
where pNbr like '1975%'

3
d.sql Normal file
View file

@ -0,0 +1,3 @@
select firstName, pNbr
from Students
where substring(pNbr, LENGTH(pNbr) -1, 1) % 2 = 0

2
e.sql Normal file
View file

@ -0,0 +1,2 @@
select distinct pNbr
from Students

3
f.sql Normal file
View file

@ -0,0 +1,3 @@
select courseName
from Courses
where courseCode like '%FMA%'

3
g.sql Normal file
View file

@ -0,0 +1,3 @@
select courseName
from Courses
where credits > 5

3
h.sql Normal file
View file

@ -0,0 +1,3 @@
select courseCode
from TakenCourses
where pNbr = '790101-1234'

4
i.sql Normal file
View file

@ -0,0 +1,4 @@
select courseName, credits, courseCode, pNbr
from Courses
join Students on Students.pNbr
where pNbr = '790101-1234'

4
j.sql Normal file
View file

@ -0,0 +1,4 @@
select sum(credits) as totalSum
from Courses
join Students on Students.pNbr
where pNbr = '790101-1234'

4
k.sql Normal file
View file

@ -0,0 +1,4 @@
select avg(TakenCourses.grade) as averageGrade, Students.pNbr
from TakenCourses
join Students on TakenCourses.pNbr = Students.pNbr
where TakenCourses.pNbr = '790101-1234'

5
l.sql Normal file
View file

@ -0,0 +1,5 @@
select avg(TakenCourses.grade) as averageGrade, TakenCourses.courseCode, Courses.courseName, sum(Courses.credits) as totalCredits
from TakenCourses
join Students on TakenCourses.pNbr = Students.pNbr
join Courses on TakenCourses.courseCode = Courses.courseCode
where Students.firstName = 'Eva Alm'

4
m.sql Normal file
View file

@ -0,0 +1,4 @@
select distinct firstName
from Students
left join TakenCourses on Students.pNbr = TakenCourses.pNbr
where TakenCourses.pNbr is null

View file

@ -1,5 +1,5 @@
DB_NAME := lab.db
SQL_FILES := init.sql lab1.sql
SQL_FILES := init.sql lab1.sql a.sql b.sql c.sql d.sql e.sql f.sql g.sql h.sql i.sql j.sql k.sql l.sql m.sql n.sql
.PHONY: all clean

7
n.sql Normal file
View file

@ -0,0 +1,7 @@
select Students.firstName, max(averageGrade) as maxAverage
from (
select Students.pNbr, TakenCourses.grade, avg(grade) as averageGrade
from Students
join TakenCourses on Students.pNbr = TakenCourses.pNbr
group by Students.pNbr
) as studentAverages