我有一个表td_cityflow_sheet_info 有sheet_id ,parent_id ,next_step_id 等字段
现在我要只通过parent_id进行分组得到next_step_id 最小的那一条的所有记录,记录中应包括所有的信息;
sheet_id 在库中是唯一的
现在我要只通过parent_id进行分组得到next_step_id 最小的那一条的所有记录,记录中应包括所有的信息;
sheet_id 在库中是唯一的
急着解决!
这个问题弄发了好久求教高手!在线等!
我通过两个分组会影响效率吗?
有没有更好的方法吗?
from
(
select a.*,row_number() over(partition by parent_id order by next_step_id) rn
from td_cityflow_sheet_info a
)
where rn=1
from td_cityflow_sheet_info
where (parent_id,next_step_id ) in
(select parent_id,min(next_step_id )
from td_cityflow_sheet_info
group by parent_id)