Last active
May 24, 2020 20:04
-
-
Save mfekadu/7b8859b521b4b3d86afa9c45f2634c80 to your computer and use it in GitHub Desktop.
Nimbus SQL Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP VIEW IF EXISTS Professor_Teaches_Section; | |
CREATE VIEW Professor_Teaches_Section AS SELECT * FROM ( | |
SELECT first_name, last_name, phone_number, research_interests, email, prof_alias_id, prof_email_alias, id_sections, section_name, instructor, alias, title, phone, office, `type`, days, `start`, `end`, location, department | |
FROM ( | |
SELECT * FROM Professors | |
JOIN (SELECT id AS prof_alias_id, substring_index(email, "@", 1) AS prof_email_alias FROM Professors) AS ProfAlias | |
ON Professors.id = ProfAlias.prof_alias_id | |
) AS ProfWithAlias | |
JOIN Sections | |
ON Sections.alias = ProfWithAlias.prof_email_alias | |
) AS Professor_Teaches_Section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP VIEW IF EXISTS Profs; | |
CREATE VIEW Profs | |
AS SELECT DISTINCT a.first_name, a.last_name, a.phone_number, a.email, c.title, c.department, b.office, b.office_hours, b.platform, b.latest_quarter, b.name, a.research_interests | |
FROM Professors a, OfficeHours b, Sections c | |
WHERE (substring_index(a.email, "@", 1) = c.alias) | |
AND (substring_index(b.email, "@", 1) = c.alias); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment