I’m an Android programmer, and I use SQLite (don’t have much choice 🙂 ) in my app.
I have a table, that contains a field of unix time stamp. Right now, if I want to make a sum of some field in this table, and group by months, I just do:
SELECT month, year, sum(x)
FROM foo
GROUP BY month, year
(Of course that the month and year are date functions).
But I want to group it by non calendar month, like from the 10th of one month, to the 10th that comes after him.
I have a very basic knowledge in SQL so I have no clue on how to do it.
Someone told me I need to use PARTITION BY but SQLite doesn’t support it.
I’m pretty sure there’s a way to do it.
Thanks in advance,
Elad
To handle the tenth of the month, you can just subtract that 10 days from the date:
You can put the year and month into separate columns. This example has them in one column.