vendredi 1 mai 2015

retrive data from sqlite by weeks

I have an app that register daily some info into SQLite DB. My table looks like this:

id data counter

and the script to create my table is:

CREATE_TABLE_SCRIPT = "CREATE TABLE " + TABLE_RESULTS_NAME + "("
        + KEY_ID + " INTEGER PRIMARY KEY," + KEY_DATA + " TEXT," + KEY_COUTER + " INTEGER DEFAULT 0" + ")";

I insert today's date, converting it in string using SimpleDateFormat and counter, everytime I press the button X. If current date is the same like last row in this DB table I just update counter column doing count++.

I can retrieve all info from DB without problems. But I'd like to retrieve SUM(counter) by weeks, for exemple 26/Apr/2015 -- 2/May/2015 and so on for all my DB records. I am trying to build my own algorithm but I realized that I am a bit confused and my deadline is soon, so I'd like to find a easy way.

Maybe somebody had the same situation, please help me.

Aucun commentaire:

Enregistrer un commentaire