diff --git a/makefile b/makefile index 2a0bd51..2f8b84a 100644 --- a/makefile +++ b/makefile @@ -7,6 +7,7 @@ all: $(SQL_FILES:.sql=.db) %.db: %.sql sqlite3 $(DB_NAME) < $< + @echo ============================== clean: rm -f $(DB_NAME) diff --git a/q.sql b/q.sql index 45b6dc2..8d5287a 100644 --- a/q.sql +++ b/q.sql @@ -1,6 +1,12 @@ --Is there more than one student with the same name? If so, who are these students? [7] -SELECT firstName, lastName, count(*) as nbrOfStudents -FROM Students -GROUP BY firstName, lastName -HAVING count(*) > 1; \ No newline at end of file +-- Selects duplicate students and counts them +-- SELECT firstName, lastName, count(*) as nbrOfStudents +-- FROM Students +-- GROUP BY firstName, lastName +-- HAVING count(*) > 1; + +-- Selects all students with the same name, no grouping +SELECT DISTINCT S1.firstName, S1.lastName, S1.pNbr +FROM Students S1, Students S2 +WHERE S1.firstName = S2.firstName AND S1.lastName = S2.lastName AND NOT S1.pNbr = S2.pNbr \ No newline at end of file