From 4ec6ff2cde25380d2445b6bcfbbfc547acdd1f4f Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Fri, 26 Jan 2024 15:53:09 +0100 Subject: [PATCH] Q fided and added separation for each script --- makefile | 1 + q.sql | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) 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