Hello,
Your main question is not what the detail explains. In the details see nothing concerning datediff
. Also you cannot select *
as you are producing totals and fields such as ID
are not relevant.
To total simply by week:
SELECT SUM("Prezzo") From "Vendite" Group by WEEK("Giorno")
For totaling week within each year:
SELECT SUM("Prezzo") From "Vendite" Group by WEEK("Giorno"), YEAR("Giorno")
Edit based upon additional request:
To add the start of a specific date, use a Where condition (date comparison is in format YYY-MM-DD):
SELECT SUM("Prezzo") As "Total", WEEK("Giorno") From "Vendite" Where "Giorno" > '2021-03-01' Group by WEEK("Giorno")
will group only dates after March 1 of 2021
Edit #2:
Please understand that this is a question and answer site. Ask a question and get an answer. Further questions should be asked as new questions. As for the latest question:
Do you know why ROW_NUMBER() doesn’t work?
Because it does not exist in HSQLDB embedded. That is v1.8 and that function was not introduced until v2.x series.
As for a numerator, this is not a normal request. Possibly use a sequence generator. See answer in this post:
Synchronise scrolling of subforms
and link in this answer:
Add AutoValue field