Q fided and added separation for each script
This commit is contained in:
parent
e7c140a319
commit
4ec6ff2cde
2 changed files with 11 additions and 4 deletions
1
makefile
1
makefile
|
@ -7,6 +7,7 @@ all: $(SQL_FILES:.sql=.db)
|
||||||
|
|
||||||
%.db: %.sql
|
%.db: %.sql
|
||||||
sqlite3 $(DB_NAME) < $<
|
sqlite3 $(DB_NAME) < $<
|
||||||
|
@echo ==============================
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(DB_NAME)
|
rm -f $(DB_NAME)
|
||||||
|
|
14
q.sql
14
q.sql
|
@ -1,6 +1,12 @@
|
||||||
--Is there more than one student with the same name? If so, who are these students? [7]
|
--Is there more than one student with the same name? If so, who are these students? [7]
|
||||||
|
|
||||||
SELECT firstName, lastName, count(*) as nbrOfStudents
|
-- Selects duplicate students and counts them
|
||||||
FROM Students
|
-- SELECT firstName, lastName, count(*) as nbrOfStudents
|
||||||
GROUP BY firstName, lastName
|
-- FROM Students
|
||||||
HAVING count(*) > 1;
|
-- 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
|
Loading…
Reference in a new issue