1.先关联出数据作为临时表a,取出最小值,然后将剩余的行数去掉最小值的行,即可
with a as (SELECT A.cus_No FROM A ,
B where B.rel_org_no(+)=A.cus_no and t.Stop_Flag='N' )
SELECT a.* from a
where usr_id in (select min(usr_Id) from users group by rel_org_no )
union
SELECT a.* from a
where cus_No not in (
SELECT cus_No from a
where usr_id in (select min(usr_Id) from users group by rel_org_no ) )
2.oracle update 序号,按照主表进行分类
update t set t.ord_seq=
(select num from (select rowid , row_number()over (partition by b.ord_no order by rowid ) num from b) c
where t.rowid=c.rowid)
with a as (SELECT A.cus_No FROM A ,
B where B.rel_org_no(+)=A.cus_no and t.Stop_Flag='N' )
SELECT a.* from a
where usr_id in (select min(usr_Id) from users group by rel_org_no )
union
SELECT a.* from a
where cus_No not in (
SELECT cus_No from a
where usr_id in (select min(usr_Id) from users group by rel_org_no ) )
2.oracle update 序号,按照主表进行分类
update t set t.ord_seq=
(select num from (select rowid , row_number()over (partition by b.ord_no order by rowid ) num from b) c
where t.rowid=c.rowid)