Created
November 25, 2016 21:20
-
-
Save jrjames83/6a7865e060bbbaaeb89088d4eae281a3 to your computer and use it in GitHub Desktop.
DVD Rental - Dates
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 p.*, | |
| -- p.payment_date::date, | |
| -- extract(year from p.payment_date), | |
| -- extract(month from p.payment_date), | |
| -- extract(day from p.payment_date) | |
| -- | |
| -- FROM payment p | |
| -- | |
| -- WHERE extract(month from p.payment_date) IN (1,2) | |
| SELECT SUM(p.amount), MAX(p.amount), MIN(p.amount), to_char(p.payment_date, 'yyyy-mm') | |
| FROM payment p | |
| GROUP BY 4 | |
| ORDER BY 1 DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment