mardi 29 décembre 2015

SQLite SUM() between several rows

I need some help with the SUM feature in android app. I have a table that looks something like the following :

enter image description here

I have need to SUM Quantities between last two records Notes and last one record with Note. I need to sum Quantity of rows 31,32 and 33. It would return 90. I've tried

SELECT Sum(QUANTITY) FROM fuel_table WHERE NOTE!='' ORDER BY ID DESC

but it returns SUM of all quantities with note.

Aucun commentaire:

Enregistrer un commentaire