首页 > 其他分享 >计算最大的连续日期天数

计算最大的连续日期天数

时间:2022-12-08 13:33:49浏览次数:51  
标签:天数 OVER 日期 分组 计算 DATE DIFF SELECT

思路:将日期天数与行号的差值作为分组条件

SELECT
DATE,
TO_DAYS(DATE)-ROW_NUMBER() OVER () DIFF -- 分组
FROM DATE
ORDER BY DATE

 

 

SELECT DIFF,COUNT(*) FROM
(SELECT
DATE,
TO_DAYS(DATE)-ROW_NUMBER() OVER () DIFF -- 分组
FROM DATE
ORDER BY DATE
) T
GROUP BY DIFF

 

标签:天数,OVER,日期,分组,计算,DATE,DIFF,SELECT
From: https://www.cnblogs.com/wangfeii/p/16965830.html

相关文章