阿里运SLS日志sql 查询统计示例
-- kuaishou_callback_externalstore 从mysql导入的表
* and clientId: 32 and action:PLAY | select createDate, count(DISTINCT(openId)) uv, count(openId) pv from log l join kuaishou_callback_externalstore k on l.openId = k.open_id and k.callback is not null and l.createDate >= '2023-03-01' and l.createDate <= '2023-03-31' and date(k.create_time) = l.createDate GROUP by l.createDate order by l.createDate limit 50
-- dts_user_spead_mark_action_externalstore 从mysq导入的表
* and action : {} and createDate: {} and clientId: {} | select count(DISTINCT(userId)) uv ,count(userId) pv , {} as type from log l join (select u.user_id,u.group_id from dts_user_spead_mark_action_externalstore u where u.create_time = '{}' and u.client_id = '{}' GROUP by u.user_id,u.group_id ) u on l.userId = u.user_id where u.group_id = {}
再来一个 三表联查 超级复杂sql 我服了我自己
| select createDate ,count(DISTINCT(p.pay_sub_user_id)) uv,count(p.pay_sub_user_id) pv ,sum(p.money_fen) as fen from ( select createDate, subUserId from log l join kuaishou_callback_externalstore k on l.openId = k.open_id and k.callback is not null and l.createDate >= '2023-03-01' and l.createDate <= '2023-03-31' and date(k.create_time) = l.createDate and l.clientId = 32 GROUP by createDate,subUserId ) pp left join dts_pay_order_externalstore p on pp.subUserId = p.pay_sub_user_id and pp.createDate = date(p.create_time) and p.pay_status =2 GROUP by createDate order by createDate
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通