delete db_selltostat where sid in(select sid from db_sell where ordertime>= to_date(to_char(sysdate-50,'yyyymmdd'),'yyyymmdd'));


insert into db_selltostat (SID,CORPID,ORDERID,PRODUCTID,PRODUCTNAME,ORDERNUM,SELLPRICE,COSTPRICE,CUSTOMERID,STORAGEID,STORAGENAME,LOCATIONID,LOCATIONNAME,ALERTFLAG,SHOPTYPEID,SHOPTYPE,OPER,OPERTIME,SELLOPER,PURCHASEOPER,RESERVE1,EBAYITEMID,TRADEID,TRANSACTIONID,MONEYTYPE,WEIGHT,WEIGHTAMOUNT,PACKAGINGID,PACKAGINGNAME,ENGLISHNAME,INSURANCE,ORDERTIME,PURCHASETIME,EXPRESSTIME,INTOTAL,INEXPRESS,OUTTOTAL,OUTEXPRESS,OUTEBAYFEE,OUTPAYPALFEE,OUTPACKAGINGFEE,MONEYRATE,SOURCE,CREATETIME,RESERVE2 
            		) select SID,CORPID,ORDERID,PRODUCTID,PRODUCTNAME,ORDERNUM,SELLPRICE,COSTPRICE,CUSTOMERID,STORAGEID,STORAGE,LOCATIONID,LOCATION,ALERTFLAG,SHOPTYPEID,SHOPTYPE,OPER,OPERTIME,selloper,oper2,oper1,EBAYITEMID,TRADEID,TRANSACTIONID,MONEYTYPE,WEIGHT,WEIGHTAMOUNT,PACKAGINGID,PACKAGINGNAME,ENGLISHNAME,ORIGININSURANCE,ordertime,XBTIME2,XBTIME3,nvl(AMOUNT,0),nvl(moneyexpressask,0),nvl(costprice*ordernum,0),nvl(moneyexpressaction,0),nvl(finalvaluefee,0),nvl(PAYPALFEE,0),nvl(SPLITPACKAGINGFEE,0),nvl(MONEYRATE,0),null,sysdate,RESERVE7 
            		 from db_sell where flag in('1','2') and ordertime>= to_date(to_char(sysdate-50,'yyyymmdd'),'yyyymmdd');