select c.object_id, c.total_time,c.total_count
from (select t.*, row_number() over(partition by t.object_id order by
t.total_time desc) rn from
t_dcmt_dbobj_log t) c
where rn = 1
本文介绍了一种使用SQL进行数据查询优化的方法,通过子查询与窗口函数结合,实现了对特定对象按总时间降序排列并选取每个对象的最高记录。此方法适用于需要快速获取各对象最佳表现场景的数据分析任务。
select c.object_id, c.total_time,c.total_count
from (select t.*, row_number() over(partition by t.object_id order by
t.total_time desc) rn from
t_dcmt_dbobj_log t) c
where rn = 1
1238
8215

被折叠的 条评论
为什么被折叠?