with t1 as
(select device_id,date_format(event_date,'%Y-%m') ym
from question_practice_detail
group by device_id,ym
having count(question_id)>1)
t2 as
(select device_id,ym,
lag(ym,1)over(partition by device_id order by ym) ym2
from t1
where period_diff(ym, ym2) = 1
select distinct device_id
from t2
不知道哪里错了
SQL59 截至当月的练题情况
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
关注 with t as (select device_id, date_format(event_date, '%Y-%m') as mon, count(*) as cnt from question_practice_detail group by device_id, mon having cnt > 1) select distinct a.device_id from t a join t b on a.device_id = b.device_id and timestampdiff(month, concat(a.mon, '-01'), concat(b.mon, '-01')) = 1 order by device_id desc;
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号
- ¥15 基于单片机的靶位控制系统
- ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
- ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
- ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
- ¥15 手机接入宽带网线,如何释放宽带全部速度