2 Answers
- Newest
- Most votes
- Most comments
1
Here's a revised version of your query with improved formatting:
SELECT DATE_ADD(DATE_FORMAT(time, '%Y-%m-%d'), INTERVAL (WEEK(time) - WEEK(DATE_FORMAT(time, '%Y-01-01'))) WEEK) AS week_start_date, SUM(duration) as duration_sum FROM "dbn"."table" GROUP BY week_start_date ORDER BY week_start_date;
The output should look like this:
week_start_date | duration_sum |
---|---|
2023-12-25 | 50 |
2024-01-01 | 122 |
2024-01-22 | 42 |
2024-01-29 | 28 |
2024-02-05 | 120 |
0
Hi Osvaldo, thanks for the reply. Did you get a chance to try the query in timestream? I got this error:
The query syntax is invalid at line 2:105
This error occurred when using WEEK as an interval
INTERVAL (WEEK(time) - WEEK(DATE_FORMAT(time, '%Y-01-01'))) WEEK
I did try to use this operator before as it is mentioned in the documentation as well but got the same error.
answered 2 months ago
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 10 months ago