惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - chenzechao

抓取 DNS 解析记录 router iStoreOS mysql starrocks json处理 json遍历数组所有元素 git复制指定提交到其他分支 secureCrt标签页固定 mac键盘 vs code settings.json StarRocks中CTE报错 shell 循环遍历的详细用法 shell变量带默认值配置 cursor自动执行 JDK17生成JRE环境 Alt+Tab切换窗口时不包括网页窗口 mysql变量使用 maven工程改版本号,支持多模块一次性修改 mysql取中位数、p80、p90 SQL自定义排序 IDEA常用快捷键 Linux环境使用上下方向键无法查看history历史记录问题解决方法 博文阅读密码验证 - 博客园 linux设置http proxy flask框架在本机可访问,而其它机子访问不了
拉链表匹配筛选日期区间
chenzechao · 2026-01-21 · via 博客园 - chenzechao
select
    *
from (
    select 1 as start,5 as end union all
    select 6 as start,10 as end union all
    select 11 as start,15 as end union all
    select 17 as start,22 as end union all
    select 23 as start,30 as end
) t1
where 1 = 1
    and (
        (start >= 2 and start <= 23)  -- 起始时间与筛选范围交集
     or (end >= 2   and end <= 23)    -- 结束时间与筛选范围交集
     or (start <= 2 and end >= 23)    -- 起始时间完全包裹筛选范围
     or (start >= 2 and end <= 23)    -- 筛选范围完全包裹起始时间
    )
;

image

       sum(
         case 
            -- 1. 店员入职日期 小于 统计开始日期,店员离职日期 大于 统计结束日期,取 统计结束日期 - 统计开始日期
            when employee_status_name in ('正式','离职') and employee_entry_date <= '${ETL_END_MON1}' and employee_disabled_date >= '${ETL_END_DATE1}'
                then (date_diff('${ETL_END_DATE1}','${ETL_END_MON1}')+1)/(date_diff('${ETL_END_DATE1}','${ETL_END_MON1}')+1)

            -- 2. 店员入职日期 大于 统计开始日期,店员离职日期 大于 统计结束日期,取 统计结束日期 - 店员入职日期
            when employee_status_name in ('正式','离职') and employee_entry_date >= '${ETL_END_MON1}' and employee_disabled_date >= '${ETL_END_DATE1}'
                then (date_diff('${ETL_END_DATE1}',employee_entry_date)+1)/(date_diff('${ETL_END_DATE1}','${ETL_END_MON1}')+1)

            -- 3. 店员入职日期 小于 统计开始日期,店员离职日期 小于 统计结束日期,取 店员离职日期 - 统计开始日期
            when employee_status_name in ('正式','离职') and employee_entry_date <= '${ETL_END_MON1}' and employee_disabled_date <= '${ETL_END_DATE1}'
                then (date_diff(employee_disabled_date,'${ETL_END_MON1}')+1)/(date_diff('${ETL_END_DATE1}','${ETL_END_MON1}')+1)

            -- 4. 店员入职日期 大于 统计开始日期,店员离职日期 小于 统计结束日期,取 店员离职日期 - 店员入职日期
            when employee_status_name in ('正式','离职') and employee_entry_date >= '${ETL_END_MON1}' and employee_disabled_date <= '${ETL_END_DATE1}'
                then (date_diff(employee_disabled_date,employee_entry_date)+1)/(date_diff('${ETL_END_DATE1}','${ETL_END_MON1}')+1)
            else 0 
        end
    ) wt_people_qty --加权店铺员工数

【腾讯文档】拉链表匹配筛选日期区间
https://docs.qq.com/board/DRVNHT0doV2drTnZk