使用(sun-sat)按周聚合

bakd9h0s  于 2021-08-01  发布在  Java
关注(0)|答案(1)|浏览(320)
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

ruoxqz4g

ruoxqz4g1#

给日期加上一天:

SELECT CONCAT(CAST(WEEK(CAST(date + INTERVAL '1' DAY as DATE)) as VARCHAR), ' - WEEK') as week,

相关问题