현재 저는 테이블로 작업는 다음과 같습니다.
Month | Transaction | amount
2021-07-01| Annual Membership Fee| 45
2021-08-01| Annual Membership Fee| 145
2021-09-01| Annual Membership Fee| 2940
2021-10-01| Annual Membership Fee| 1545
이 amount
에는 테이블은 총 월량(ex. 100 고객 paid$15 에 대한 연례 회원,그래서 내 월 총 금액 것$1500).
그러나 내가 무엇을 하고 싶은 것(나는 단서를 어떻게)은 나눈 금액으로 12 으로 확산에서 미래를 위해 매달 revenue per month. 로에 대한 예 2021-09-01 나는 다음과 같은 결과가 나타납니다
$2490/12 = $207.5 (dollars per month for the next 12 months)
in 2021-09-01 I would only get $207.5 for that specific month.
On 2021-10-01 I would get $1545/12 = $128.75 plus $207.5 from the previous month (total = $336.25 for 2021-10-01)
And the same operation would repeat onwards. The last period that I would collect my $207.5 from 2021-09-01 would be in 2022-08-01.
었는지 궁금하다면 누군가 쉽게 확인할 수 있게 되었습니다 아이디어를 수행하는 방법이에서 SQL 쿼리/CTE?