Created
November 7, 2016 21:54
-
-
Save kevincolten/235ae1d7db713b1d79512814c78da8b0 to your computer and use it in GitHub Desktop.
Campus Manager Report Queries
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
SELECT idn, first_name, last_name, email, phone, COUNT(users.email) as courses | |
FROM users | |
INNER JOIN registrations ON users.id = registrations.user_id | |
GROUP BY users.email | |
HAVING COUNT(users.email) < 3 AND COUNT(users.email) > 1 | |
ORDER BY courses DESC, cast(idn as Number) ASC; |
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
SELECT idn, first_name, last_name, email, phone, city | |
FROM users | |
JOIN registrations ON users.id = registrations.user_id | |
JOIN courses ON registrations.course_id = courses.id | |
JOIN terms ON terms.id = courses.term_id | |
JOIN locations ON term.location_id = locations.id | |
GROUP BY users.email; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment