diff --git a/answers/exercise1.sql b/answers/exercise1.sql index e69de29..833909a 100644 --- a/answers/exercise1.sql +++ b/answers/exercise1.sql @@ -0,0 +1,27 @@ +CREATE TABLE Enrollment ( + FirstName VARCHAR(255), + LastName VARCHAR(255), + Adress VARCHAR(255), + City VARCHAR(255), + StudentID VARCHAR(100), + Hobby VARCHAR (255), + Skills VARCHAR (255)); + +INSERT INTO Enrollment ( +FirstName, +LastName, +Adress, +City, +StudentID, +Hobby, +Skills) +VALUES ( +'John', +'Song', +'76 gggg St', +'Philly', '3', +'Games', 'Coding'); + +SELECT * FROM Enrollment +LEFT JOIN Students ON Enrollment.StudentID = Students.StudentID; + diff --git a/answers/exercise2.sql b/answers/exercise2.sql index e69de29..17def18 100644 --- a/answers/exercise2.sql +++ b/answers/exercise2.sql @@ -0,0 +1,3 @@ +SELECT * FROM Enrollment +INNER JOIN Students +ON Enrollment.StudentID = Students.StudentID; \ No newline at end of file diff --git a/answers/exercise3.sql b/answers/exercise3.sql index e69de29..a731efd 100644 --- a/answers/exercise3.sql +++ b/answers/exercise3.sql @@ -0,0 +1,3 @@ +SELECT * FROM Enrollment +RIGHT JOIN Students +ON Enrollment.StudentID = Students.StudentID; \ No newline at end of file diff --git a/answers/exercise4.sql b/answers/exercise4.sql index e69de29..608d94a 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..794a1ff 100644 --- a/answers/exercise5.sql +++ b/answers/exercise5.sql @@ -0,0 +1,3 @@ +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..0c1b460 100644 --- a/answers/exercise6.sql +++ b/answers/exercise6.sql @@ -0,0 +1,4 @@ +SELECT Country, COUNT(*) FROM Students +GROUP BY Country +HAVING COUNT(*) > 10 +ORDER BY COUNT(*); \ No newline at end of file