I have a database where there are sales .
+----+-----------+------------+
| ID | Quantity | DATE |
+----+-----------+------------+
| 1 | 40 | 2020/10/10 |
| 2 | 0 | 2020/10/01 |
| 3 | 10 | 2020/10/11 |
+----+-----------+------------+
And i want this result :
+------------+----------+------------+
| OPERATION | Resultat | DATE |
+------------+----------+------------+
| 40 - 0 | 40 | 2020/10/10 |
| 0 - 40 | -40 | 2020/10/01 |
| 10 - 0 | 10 | 2020/10/11 |
+------------+----------+------------+
I mean get the sum of the value of date – value of yersterday
could someone give me an idea of how i could write this simply?
Thank you in advance
Best Answer
The data don't fit your wanted resuLt, so i had to change the date
Schema (SQLite v3.30)
Query #1
View on DB Fiddle