sql >> データベース >  >> RDS >> Oracle

フォローアップ Q:Oracle テーブルの行を比較し、一致する行を更新する

    update your_table set status='Matched' where id in( with IDS(id1,id2,grp,num,rnum) as( select a.id,b.id, rank() over(order by a .tdate,a.price,a.product,a.quantity) の場合、a.id=lag(a.id) over(partition by a.tdate,a.price,a.product,a.quantity order by a. .id) then 0 else dense_rank() over(a.tdate,a.price,a.product,a.quantity によるパーティション分割) end, row_number() over(a.tdate,a.price によるパーティション分割) ,a.product,a.quantity order by a.id) from your_table a, your_table b where a.tdate=b.tdate and a.price=b.price and a.product=b.product and a.quantity=b .quantity および a.buysell='Sell' および b.buysell='Buy' および a.description!=b.description ), Q(id1,id2,grp,num,used) as( select id1,id2,grp, IDS からの num,','||id2||',' ここで、rnum=1 の共用体はすべて I.id1,​​R.column_value,Q.grp,Q.num+1,Q.used||R.column_value|| を選択します。 ',' Q、IDS I、table(cast(multiset( N.id1=I.id1 および Q.used から IDS N から min(id2) id を選択します。 =Q.grp and I.num=Q.num+1 ) select decode(X,1,id1,id2) from Q, (select 1 X from DUAL union all select 2 from DUAL) where id2 is not null)  


    1. 接続が拒否されました(PGError)(postgresqlおよびrails)

    2. DateTime を主キーとして使用する SQL Server

    3. サブカテゴリを含む関連する行をカウントする方法は?

    4. PROCESSESのMAX_UTILIZATIONに到達すると、管理対象接続の例外を取得できませんか?