I need to extend this question: SQLite SUM() between several rows Before table was
and query was :
SELECT Sum(SERVICE)
FROM (
SELECT ft.*, (
SELECT count(*)
FROM fuel_table ft2
WHERE ft2.note='Your tank was full up.' and ft2.id>=ft.id)
AS numNotesAhead
FROM fuel_table ft)
AS ft
WHERE numNotesAhead=1
but now my fuel table is split and looks like:
I've tried:
SELECT Sum(fuel_table.SERVICE)
FROM (
SELECT ft.*, (
SELECT count(*)
FROM fuel_table ft2
LEFT JOIN note_table ON fuel_table.EnterId = note_table.EnterId
WHERE ft2.note='Your tank was full up.' and ft2.id>=ft.id)
AS numNotesAhead
FROM fuel_table ft)
AS ft
WHERE numNotesAhead=1
but it doesn't works. My app just stops.
*Note there is "_" in name of fuel table.
Aucun commentaire:
Enregistrer un commentaire