vendredi 17 juillet 2015

How to select the first day of each month for the last 12 months in sqlite?

I have two columns date and name. I was wondering if there was a way in Sqlite to find name for the first day of each month for the last 12 months.

I was thinking of doing something of the like:

SELECT name, date FROM table WHERE date = date('now','start of month','-1month') OR date = date('now','start of month','-2 month') [...] OR date = date('now','start of month','-12 month')....

But it's pretty ugly and I figured there should be another way ...

Aucun commentaire:

Enregistrer un commentaire