合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
复杂查询sql 1:场景(章节跳出率分日看板:需要指定范围区间的阅读每本书的每个章节,每个章节的阅读uv,连续阅读章节的uv,由于无法知道搜索的具体的哪个日期,因此只能实时查询) ``` with op as (SELECT DISTINCT user_id,book_id,sort_id FROM `fq_chapter_rack_distincts` WHERE `date` >= 20240607 AND `date` <= 20250415 and book_id = 14612) ,op1 as (SELECT user_id, book_id, sort_id, lead(sort_id,1,null) over(partition by user_id,book_id order by sort_id) next_sort_id from op) select book_id, sort_id, count(user_id) read_uv, count(case when next_sort_id is not null and next_sort_id - sort_id = 1 then user_id else null end) read_next_sort_uv from op1 group by book_id,sort_id ```