17,377
社区成员
发帖
与我相关
我的任务
分享
select * from (
select tbgc_id,ass_segment1,std_item_id,creation_date,
row_number() over(partition by std_item_id order by creation_date desc) rn
from zdoe_tbgc_head
) where rn = 1;
select zth.tbgc_id,zth.ass_segment1,zth.std_item_id,zth.creation_date
from zdoe_tbgc_head zth
where zth.std_item_id in
(select std_item_id
from zdoe_tbgc_head t
where std_item_id = zth.std_item_id)
--你这个sql应该不能找到重复的std_item_id的吧
select * from (
select tbgc_id,ass_segment1,std_item_id,creation_date,
row_number()over(partition by std_item_id order by creation_date desc)
rn from zdoe_tbgc_head where std_item_id=some(
select std_item_id from zdoe_tbgc_head group by std_item_id having count(1)>1
)) where rn=1
--看下这个是不是你要结果
select * from zdoe_tbgc_head zth
where creation_date=(select max(creation_date)
from zdoe_tbgc_head zth1 where zth.std_item_id=zth1.std_item_id);