SELECT
CONCAT(CAST(WEEK(CAST(date as DATE)) as VARCHAR), ' - WEEK') as week,
COUNT(DISTINCT(field1)) as field1_count,
SUM(amount) as amount
FROM table
WHERE SUBSTR(DATE, 1, 4) = '2020'
GROUP BY 1
ORDER BY 1
是否可以确保此处的汇总为Sun - Sat
?当前在Mon - Sun
答案 0 :(得分:1)
在日期前增加一天:
SELECT CONCAT(CAST(WEEK(CAST(date + INTERVAL '1' DAY as DATE)) as VARCHAR), ' - WEEK') as week,