diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..1ff702b Binary files /dev/null and b/.DS_Store differ diff --git a/answers/exercise1.sql b/answers/exercise1.sql index e69de29..f07b1dd 100644 --- a/answers/exercise1.sql +++ b/answers/exercise1.sql @@ -0,0 +1,24 @@ +USE myNewDb; +CREATE TABLE Enrollments( +StudentId int, +StudentName VARCHAR(255)); +CREATE TABLE Learners( +StudentId int, +StudentName VARCHAR(255)); +INSERT INTO Enrollments( +StudentId, +StudentName) +VALUES( +4, +'Mike'); +SELECT * FROM Enrollments; +INSERT INTO Learners( +StudentId, +StudentName) +VALUES( +7, +'Takeoff'); +SELECT * FROM Enrollments +RIGHT JOIN Learners +ON Enrollments.StudentId += Learners.StudentId; \ No newline at end of file diff --git a/answers/exercise2.sql b/answers/exercise2.sql index e69de29..0c875e5 100644 --- a/answers/exercise2.sql +++ b/answers/exercise2.sql @@ -0,0 +1,4 @@ +SELECT * FROM Enrollments +INNER JOIN Learners +ON Enrollments.StudentId += Learners.StudentId; \ No newline at end of file diff --git a/answers/exercise3.sql b/answers/exercise3.sql index e69de29..7ac2c46 100644 --- a/answers/exercise3.sql +++ b/answers/exercise3.sql @@ -0,0 +1,4 @@ +SELECT * FROM Enrollments +RIGHT JOIN Learners +ON Enrollments.StudentId += Learners.StudentId; \ No newline at end of file diff --git a/answers/exercise4.sql b/answers/exercise4.sql index e69de29..71c941f 100644 --- a/answers/exercise4.sql +++ b/answers/exercise4.sql @@ -0,0 +1,3 @@ +SELECT COUNT( * ), Country +FROM Students +GROUP BY Country; \ No newline at end of file diff --git a/answers/exercise5.sql b/answers/exercise5.sql index e69de29..0e333d0 100644 --- a/answers/exercise5.sql +++ b/answers/exercise5.sql @@ -0,0 +1,4 @@ +SELECT COUNT( * ), Country +FROM Students +GROUP BY Country +ORDER BY COUNT(*) DESC; \ No newline at end of file diff --git a/answers/exercise6.sql b/answers/exercise6.sql index e69de29..345d37f 100644 --- a/answers/exercise6.sql +++ b/answers/exercise6.sql @@ -0,0 +1,5 @@ +SELECT COUNT( * ), Country +FROM Students +GROUP BY Country +HAVING COUNT(*) > 10 +ORDER BY COUNT(*); \ No newline at end of file