Created
September 2, 2017 09:02
-
-
Save Lewiscowles1986/d7c9a4195a67034b1d77fe67420b2b75 to your computer and use it in GitHub Desktop.
Nice monthly breakdown SQL
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
/* | |
* Uses MySQL SQL Syntax | |
*/ | |
SELECT | |
YEAR(O.`when`) as `year`, | |
MONTH(O.`when`) as `month`, | |
COUNT(O.id) as `Orders Passed`, CONCAT('$',(COUNT(O.id) * 2)) as `earned` | |
FROM middleware.order_link O | |
GROUP BY `year`, `month` | |
UNION | |
SELECT | |
NULL as `year`, | |
NULL as `month`, | |
COUNT(O.id) as `Orders Passed`, | |
CONCAT('$',(COUNT(O.id) * 2)) as `earned` | |
FROM middleware.order_link O |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment