一、對bz的最新入庫儲位刷資料的過程
1、刪除表qwe_t,
drop table qwe_t;
2、讓後建立臨時表
create table qwe_t(
ent number(5),
site varchar2(20),
liao varchar2(20),
ku varchar2(20),
chu varchar2(20),
no varchar2(40)
);3、按照需求查詢出你需要的資料
select a.* from (
select distinct imafent,imafsite,pmdt006,imaf091,pmdt017,pmdtdocno from pmdt_t left join imaf_t on imaf001=pmdt006
and pmdtent = imafent and pmdtsite = imafsite and pmdt016 = imaf091 and imafent=88
) a ,pmds_t where 1=1 and pmdsent = a.imafent and pmdssite = a.imafsite and pmdsdocno = a.pmdtdocno and pmds000 in ('6','12')
and pmdsent=88
4、將查詢出的資料插入到臨時表中
/*將查詢的資料插入臨時表中*/
insert into qwe_t
select a.* from (
select distinct imafent,imafsite,pmdt006,imaf091,pmdt017,pmdtdocno from pmdt_t left join imaf_t on imaf001=pmdt006
and pmdtent = imafent and pmdtsite = imafsite and pmdt016 = imaf091 and imafent=88
) a ,pmds_t where 1=1 and pmdsent = a.imafent and pmdssite = a.imafsite and pmdsdocno = a.pmdtdocno and pmds000 in ('6','12')
and pmdsent=88
5、刪除臨時表中的資料與要插入的表中資料重複的資料
/*刪除主鍵重複的資料*/
delete from qwe_t where exists(select 1 from inaauc_t where ent=inaaucent and site=inaaucsite and liao=inaauc001
and ku=inaauc002 )
6、查詢臨時表中的資料按照目標表的主鍵的字段查詢資料,去除主鍵重複資料
select s.ent,s.site,s.liao,s.ku,s.chu,'y'
from (
select qwe_t.*, row_number() over (partition by ent,site,liao,ku order by chu) as group_idx
from qwe_t
) swhere group_idx=1
7、將符合條件的資料插入到目標表中
/*插入inaauc_t中*/
insert into inaauc_t(inaaucent,inaaucsite,inaauc001,inaauc002,inaauc003,inaaucstus )
select s.ent,s.site,s.liao,s.ku,s.chu,'y'
from (
select qwe_t.*, row_number() over (partition by ent,site,liao,ku order by chu) as group_idx
from qwe_t
) swhere group_idx=1
二、本次刷資料的經驗
1、本次刷資料的第一步在查詢出資料的時候,對主表、從表的分析不夠,導致查詢出得資料重複的資料太多,所以在查詢資料是應仔細考慮到查詢資料的主從的關係;
2、對第六步中使用的查詢使用的分析函式的使用是本次的主要收穫;
row_number() over (partition by ent,site,liao,ku order by chu【asc|desc】) 說的是將查詢結果按照
ent,site,liao,ku 字段分割槽,然後每個分割槽裡面的資料再按照chu 的優先順序順序排序, 至於asc (正序)和desc(倒序) 就是公升序和降序了,可以不寫,預設是asc(正序);
select qwe_t.*, row_number() over (partition by ent,site,liao,ku order by chu) as group_idx
from qwe_t
這個查詢語句的目的是按照 ent,site,liao,ku
字段分割槽,然後每個分割槽裡面的資料再按照
chu
的優先順序順序排序給每一筆資料增加乙個排序的序號 欄位名稱為:group_idx 所以在第六步數有了查詢條件為 group_idx=1 ,也就是按照ent,site,liao,ku 後每個區只查詢出一筆資料;
jstree重新整理資料
網上資源太少,好不容易在stackoverflow上搜到乙個可以用的,本來想自己手寫乙份的,但是正好網上找到了一篇不錯的,所以,嘿嘿嘿。話不多說,直接看 ready function xreload on click null,function e 關鍵點 tree.jstree true sett...
iOS cell重新整理資料
區域性重新整理方法 新增資料 nsarray indexpaths nsindexpath indexpathforrow 0 insection 0 nsindexpath indexpathforrow 1 insection 0 self tableview insertrowsatindex...
Listview重新整理資料
本質上是listview繫結adapter,adapter關聯list,因此list變化後導致adapter同步變化 再通過呼叫adapter.notifydatasetchanged 方法使得listview介面自動更新。操作 liststrname new arraylist 實際的資料來源 a...