Created
May 20, 2013 18:12
-
-
Save pierre/5614091 to your computer and use it in GitHub Desktop.
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 | |
effective_date | |
, cur_period_rev.recognized_amount + past_period_rev.recognized_amount | |
from ( | |
select | |
effective_date | |
, recognized_amount | |
from recognized_revenue | |
where recognized_date = date_format(curdate(), '%Y-%m-01') | |
and effective_date >= date_format(curdate(), '%Y-%m-01') | |
) cur_period_rev | |
cross join ( | |
select | |
sum(recognized_amount) recognized_amount | |
from recognized_revenue | |
where recognized_date = date_format(curdate(), '%Y-%m-01') | |
and effective_date < date_format(curdate(), '%Y-%m-01') | |
and effective_date = last_day(effective_date) | |
) past_period_rev | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment