Created
April 3, 2024 20:27
-
-
Save ecwyne/a30d838f16abc8d1844250b17ca4a840 to your computer and use it in GitHub Desktop.
Queries to get you started
This file contains hidden or 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 | |
offices.id AS office_id, | |
offices.abbr AS metro_area, | |
substr (payments.date, 1, 7) AS mnth, | |
SUM(payments.amount) AS amount | |
FROM | |
payments | |
INNER JOIN transactions ON transactions.id = payments.transaction_id | |
INNER JOIN customers ON customers.id = transactions.customer_id | |
INNER JOIN offices ON offices.id = customers.office_id | |
WHERE | |
payments.entered = TRUE | |
AND payments.date >= '2020-01-01' | |
GROUP BY | |
mnth, | |
office_id; |
This file contains hidden or 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 | |
students.state, | |
substr (payments.date, 1, 7) AS mnth, | |
SUM(payments.amount) AS amount | |
FROM | |
payments | |
INNER JOIN transactions ON transactions.id = payments.transaction_id | |
INNER JOIN customers ON customers.id = transactions.customer_id | |
INNER JOIN offices ON offices.id = customers.office_id | |
INNER JOIN sc ON sc.customer_id = customers.id | |
INNER JOIN students ON students.id = sc.student_id | |
WHERE | |
payments.entered = TRUE | |
AND payments.date >= '2020-01-01' | |
GROUP BY | |
mnth, | |
state; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment