How to group by week, indicating the day of the end of the week?

I need to run a report, grouped by week. This can be done using group by week(date), but the client wants to set the day of the week that marks the end of the week. So it could be Tuesday, Wednesday, etc. How can I work with this in a group on request?

The datetime column type is a unix timestamp.

+3
source share
1 answer

The function WEEK()accepts an optional second parameter to indicate the start of the week:

. WEEK() , , 0 53 1 53.

.


: , WEEK(DATE_ADD(date INTERVAL x DAY)), . , triggers, , date . .

+4

Source: https://habr.com/ru/post/1765751/


All Articles