P and Q fixed
This commit is contained in:
parent
d85132eb46
commit
f95ec89d9f
3 changed files with 15 additions and 1 deletions
2
makefile
2
makefile
|
@ -1,5 +1,5 @@
|
|||
DB_NAME := lab.db
|
||||
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 o.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 o.sql p.sql q.sql
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
|
|
10
p.sql
Normal file
10
p.sql
Normal file
|
@ -0,0 +1,10 @@
|
|||
DROP VIEW IF EXISTS StudentsCredits;
|
||||
|
||||
CREATE VIEW StudentsCredits AS
|
||||
SELECT Students.firstName, sum(credits) as totalCredits
|
||||
FROM Students
|
||||
JOIN TakenCourses ON Students.pNbr = TakenCourses.pNbr
|
||||
JOIN Courses ON TakenCourses.courseCode = Courses.courseCode
|
||||
GROUP BY Students.pNbr;
|
||||
|
||||
SELECT * FROM StudentsCredits ORDER BY totalCredits DESC;
|
4
q.sql
Normal file
4
q.sql
Normal file
|
@ -0,0 +1,4 @@
|
|||
SELECT firstName, lastName, count(*) as nbrOfStudents
|
||||
FROM Students
|
||||
GROUP BY firstName, lastName
|
||||
HAVING count(*) > 1;
|
Loading…
Reference in a new issue