jeudi 8 octobre 2015

How to select unique month-year combinations from SQLite database using OrmLite?

I have a table with data and having a column with a date value.

Table A
table_id     date

So think of the table as to have more than thousands of rows and entries. What I want to do is to select all the distinct months and years from the table, so the output would probably look something like this:

Output
09  2013  09-2013
12  2014  12-2014
01  2015  01-2015
03  2015  03-2015
05  2015  05-2015

Maybe something like this? If this is possible?

dao.queryBuilder().distinct().selectColumns("strftime('%mm-%yyyy', date)").query();

But I can't seem to make the above work the way I want it to. My model also uses the DataType.DATE on its date field.

Is there some way I can use the distinct() method of OrmLite to return this kind of list? Any help would be greatly appreciated! Thank you!

Aucun commentaire:

Enregistrer un commentaire