SELECT
year_and_moth,
count_per_month,
(
SELECT
SUM(count_per_month)
FROM
test_table AS test_table_1
WHERE
test_table_1.year_and_moth <= test_table_2.year_and_moth
) AS total_by_month
FROM
test_table AS test_table_2
按月累计
sqlite好像用不了 sum() over
-------------
SELECT R1.类别, R1.月份, SUM(R2.Revenue)
FROM Revenue R1, Revenue R2
WHERE
R1.ID >= R2.ID
AND R1.类别 = R2.类别
GROUP BY R1.月份, R1.类别
ORDER BY R1.ID, R1.类别 , R1.月份;
