Help needed to build delete statement

i need to keep last 10 days data+ last day of everymonth data in my table.
this table will grow on daily basis.
ex:
data_date no.of records
2006/02/28 10000
2006/03/31 11000
2006/04/30 12000
2006/05/31 13000
2006/06/09     13100
2006/06/10 13200
2006/06/11 13300
2006/06/12 13400
2006/06/13     13500
2006/06/14     13600
2006/06/15 13700
2006/06/16 13800
2006/06/17     13900
2006/06/18     14000
means last 10 days + last day of evermonth data need to store and remaining all
records i need to delete from this table.
could you help me to build this delete statement in single statement.

select * from mytbl;
DD                 NR
28-02-2006      12000
31-03-2006      10000
30-04-2006      12050
31-05-2006       9500
06-06-2006      13100
07-06-2006      13200
08-06-2006      13300
09-06-2006      13400
10-06-2006      13500
11-06-2006      13600
12-06-2006      13700
13-06-2006      13800
14-06-2006      13900
15-06-2006      14000
16-06-2006      14100
17-06-2006      14200
18-06-2006      14300
17 rows selected.
delete from mytbl
where not
( dd = last_day( dd ) -- Keep last days of months
   or  dd >= trunc(sysdate) - 10 -- Keep last 10 days
3 rows deleted.
select * from mytbl;
DD                 NR
28-02-2006      12000
31-03-2006      10000
30-04-2006      12050
31-05-2006       9500
09-06-2006      13400
10-06-2006      13500
11-06-2006      13600
12-06-2006      13700
13-06-2006      13800
14-06-2006      13900
15-06-2006      14000
16-06-2006      14100
17-06-2006      14200
18-06-2006      14300To me...it looks like it does work!

Similar Messages

  • Help needed in building query

    Tab1
    Parent       Child       sa l
    P1     A1       4000
    A1     A       1000
    A1     B       4000
    A     X       1000
    A     Y         2000
    B     X1        1000           
    B     X2       3000I need to build a query that will retrieve the value for each child as the sum of the salaries of all its child in a single query.
    That is
    For Sal P1 = Sal A1 + all child of A1 and its child
         For A1 = Sal A1 + all child of A1 and its child ( A+B+X+Y+X1+X2)
    Like it should sho all the records with the count .. please help

    This is not so simple since it is not really clear in your data set whether the sal belongs to the parent or to the child. I assume it's the salary of the child, in which case the salary of P1 is missing. The best option is to fix the data model and have two tables: one containing the element and sal, and another table containing just the relationships. To fix this issue I introduced a dummy record for P1 and salary 0.
    SQL> with t2 as
      2  ( select connect_by_root(child) cbr
      3         , sal
      4      from (select * from t union all select null,'P1',0 from dual)
      5   connect by parent = prior child
      6  )
      7  select cbr child
      8       , sum(sal)
      9    from t2
    10   group by cbr
    11  /
    CHILD    SUM(SAL)
    X1           1000
    A1          16000
    X2           3000
    P1          16000
    Y            2000
    X            1000
    A            4000
    B            8000
    8 rows selected.Regards,
    Rob.

  • Help needed to build simple BRF

    Hi,
    I am new to BRF and wanted some help from you building a simple BRF, say a look up from the database table.

    Hi,
    I guess you are trying to use BRF function from custom application and not talking about Process-Controlled Workflow.
    Yes. You can use BRF from custom application. BRF is just one of functions delivered in NetWeaver level.
    http://help.sap.com/saphelp_scm70/helpdata/EN/9a/6b67ce7c26446483af079719edf679/frameset.htm
    http://help.sap.com/saphelp_scm70/helpdata/EN/d6/38bb4006d9cc38e10000000a155106/frameset.htm
    Regards,
    Masa

  • Urgent help needed in building an expression

    hi,
    I am using expression editor to build the following simple expression.
    "if inputvalue = 0 then 10 else 20"
    so Far I have used various forms of "IF" and "CASE" statements but could not successfully create the expression.Could not find anything useful in the help docs as well.
    any help asap would be highly appreciated..highly disappointed with OWB which does not allow to build such a simple expression and the user docs as well are very poor.

    Hi,
    There is something you need to know up front on expressions and transformations. Expressions are SQL expressions, whereas transformations are pl/sql.
    Looking at your pseudo code, you are trying to do a procedural thing. So there are 2 ways of doing this. One is correctly the case statement. For an example on how to do this go to the OWB sample code page on OTN (http://otn.oracle.com/sample_code/products/warehouse/content.html) where an explanation is given on how to do this. It includes an example metadata file for you to evaluate.
    The other way of doing this is in PL/SQL, in which case you would create a small function accepting in parameter and then doing the procedural language on that. To create this use the create functions activity in OWB. Here you will get a nice code editor (similar to the expression builder) to guide you in the creation of this function.
    Hope this helps,
    Jean-Pierre

  • ICal Help Needed! (cannot delete calendars/events on computer and iPhone)

    Hi Everyone,
    I need some help with my iCal. Background info:
    -Currently have an iPhone 3GS
    -Using Google Calendar
    -Use separate calendar on iPhone (Pocket Informant)
    -Wanted to sync all event from Outlook to Google Calendar to iCal to two calendars on phone (this became an issue with alarms so began attempting to delete all events from the original iPhone calendar that I do not want to use)
    I started by syncing my Outlook (one way) with my Google Calendar, which syncs with the iCal on computer and Pocket Informant on iPhone, as well as iCal on iPhone. Duplicate alarms started occurring on the phone (PI and iCal). I then attempted to delete all events from the iCal on the computer. One calendar remains, one that I subscribed to from Yahoo Sports. I have tried everything to delete this calendar, but it seems impossible. After I sync the phone, the subscribed calendar shows up as well as birthdays and one calendar from my Google Calendar, on my phone.
    So, the issues, and what I would eventually like to see:
    1. I would like all events cleared from iCal on computer (currently just subscribed calendar that will not delete)
    2. I would like to delete all events from calendar on phone (subscribed calendar, birthdays, and one calendar from Google) *I cannot even delete these events by hand on my phone.
    3. In the end I would like to just continue to sync Outlook with Google which syncs with PI and then do nothing with iCal (on phone and computer) *Well really I would like events from Google synced with iCal on computer, but this doesn't seem feasible so I would settle with not using it at all.
    The only thing I can think of to do at this point is to delete iCal, but I am not even sure this would correct the calendar issue on my phone as I am unable to delete that and the sync does not seem to be working correctly.
    Any help on this would be much appreciated!
    Thank you in advance!!

    The edit feature was working correctly with the calendars and stopped. Performed a sync through iTunes removing syncing preferences first. Did not resolve the issue. I am considering restoring the iphone.

  • Help needed in building a tree without duplicatin​g the nodes

    Iam trying to construct a tree, ID name as the parent node and channel name & channel values as its corresponding child nodes.
    I had constructed the tree, but the problem i have is with interfacing that with in my  main program. In the main program say suppose I have 5 Id's, each Id has some X number of channel's. And each channel has a value.
    Each Id is indexed and passed to the for loop. And since this for loop is inside the while loop each ID will be executed for every 5 iterations.
    Id, channel names will be constant each time it gets executed, but the channel value's will be updated during run time.
    If I directly feed the Id, channel names and values, replacing the constants in the vi, the tree is duplicating the messages, each time a ID is received inside the for loop, it is creating a new parent and child nodes.
    Please help me in fixing this issue, and constructing the tree, where the ID and channel names are not not duplicated.For better understanding Iam attaching a snapshot shot, which tells at what point the ID, channel name array and value is received.
    Attachments:
    channel_info.vi ‏31 KB
    channel.png ‏60 KB

    Caleb Harris, the arbitration ID is not the same each time. Cluster has several different id's, this can be seen in the attached screen shot. Attached sreen shot shows the cluster information,  a sample ID unbundled from the array and the list of channels in that Arbitration ID. I got an idea how to construct the tree but for that,
    1)Need to store all this arbitartion Id's,channel's , and values in 3- different arrays (Channel array and the values array must have the same size).
    2)Channel array must be in synchronus with the Value array say like the first index value of the value_array  should represent the value of the first element of the channel    
       array, similarly the second index value of the value_array  should represent the value of the second element of the channel array and so on.
    3) When ever the channel value gets updated, that particular element of the value array should be updated.
    If I can do this 3- steps I think I can succesfully build a tree. Can you please take a look at the snapshot and help me out in doing this.
    Attachments:
    Cluster Image.PNG ‏67 KB

  • Help Needed in Building JTree

    HI,
    I've a doubt in Building a JTree.It wud be helpful if some one helps me with a better logic for building this Tree..
    I have a tree like this:
    root
    |
    A--B--C--D
    A--B--C--D
    A--B--C
    A--B--C--E--F
    I have the tree nodes like this . i need to merge the nodes like this
    root
    |
    A
    |
    -- B
    |
    --C
    |
    --D
    --E
    |
    --F
    I've tried it in few ways. It doesn't seems to be working.. Can some one help me in giving me a better logic in doing this

    Hello,
    When updating the tree, do not access the tree nodes directly. Update the tree via its (TreeModel).
    to get the model of your JTree use
    DefaultTreeModel treeModel = (DefaultTreeModel)myTree.getModel();to add nodes use the method
    treeModel.insertNodeInto(newChild,parent,offset);and remove nodes using
    treeModel.removeFromParent(nodeToRemove);--
    Regards,
    Ahmed Saad

  • Java code help needed for If-elseif statement

    HI All,
    Apologies for posting such a trivial thing but I am a novice in Java.
    All I need is to code an If elseIF statement.
    I tried the code below
    String w = "SAPA";
    String x = "SAPB";
    if (a==w) ;
    {Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP");}
    else if (a==x)
    { Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP_ECQ"); }
    It came back with the error
    Source code has syntax error:  D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map695b77619ad011dd8d0b001a4b52813a/source/com/sap/xi/tf/_MM_TRANSMISSION_CHECK_TO_GENIUS_.java:324: 'else' without 'if' else if (a==x) ^ 1 error
    Appreciate if you could let me know the correct code.
    Many thanks
    Shirin

    HI Aamir,
    After I removed the semi-colon iIt came back with the following error
    Source code has syntax error:  D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map1d9b43e09ad111dd84b7001a4b52813a/source/com/sap/xi/tf/_MM_TRANSMISSION_CHECK_TO_GENIUS_.java:328: cannot resolve symbol symbol : variable channel location: class com.sap.xi.tf._MM_TRANSMISSION_CHECK_TO_GENIUS_ accessor = LookupService.getRfcAccessor(channel); ^ 1 error
    Just for reference my entire Jave UDF looks like this:
    //write your code here
    String w = "SAPA";
    String x = "SAPB";
      String content = "";
    MappingTrace importanttrace;
    importanttrace = container.getTrace() ;
    //Filling the string with our RFC-XML (With Values)
    String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZIFMS_GET_NEXT_NUMBER xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><I_NR_RANGE_NR>01</I_NR_RANGE_NR><I_OBJECT>ZIFMS_INT</I_OBJECT></ns0:ZIFMS_GET_NEXT_NUMBER>";
    RfcAccessor accessor = null;
    ByteArrayOutputStream out = null;
    try
    //1. Determine a channel (Business System, Communication channel)
    if (a==w)
    {Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP");}
    else if (a==x)
    { Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP_ECQ"); }
    //2. Get a RFC accesor for a channel.
    accessor = LookupService.getRfcAccessor(channel);
    //3. Create a xml input stream representing the FM request message.
    InputStream inputstream = new ByteArrayInputStream(m.getBytes());
    //4. Create xml Payload
    XmlPayload payload = LookupService.getXmlPayload(inputstream);
    //5. Execute Lookup
    Payload result = accessor.call(payload);
    InputStream in = result.getContent();
    //This are the extra step which i dont know what it mean
    //out = new ByteArrayOutputStream(1024);
    //byte[] buffer = new byte1024;
    //for (int read = in.read(buffer); read > 0; read = in.read(buffer))
    //out.write(buffer,0,read);
    //content = out.toString();
    try {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(in);
    NodeList list = document.getElementsByTagName( "E_NUMBER" );
    Node node = list.item(0);
    if (node != null)
    node = node.getFirstChild();
    if (node != null)
    content = node.getNodeValue();
    } catch (Exception e) {
    importanttrace.addWarning("Error while closing accesor" + e.getMessage());
    catch (LookupException e)
    importanttrace.addWarning("Error While lookup" + e.getMessage());
    //This exception is not to be catch at this step as there is no try step before this
    //catch (IOException e)
    //importanttrace.addWarning("Error" + e.getMessage());
    finally
    if(out!=null)
    try{
    out.close();
    } catch (IOException e) {
    importanttrace.addWarning("Error while closing system" + e.getMessage());
    //7. close the accessor in order to free resources
    if (accessor!=null) {
    try{
    accessor.close();
    } catch (Exception e) {
    importanttrace.addWarning("Error while closing accesor" + e.getMessage());
    return content;

  • Help needed - E-mail Deleted from server

    Hello Everyone !
    I just got my Z30 a week ago , and hope i get help with this
    My problem is that i realized that some e-mails of my gmail account are not on web server but are on my phone , yet iam sure i didn't Delete any mails from my Z30 !
    I really need that my BB wouldnt download e-mails and delete them from server , i need them to be on gmail whenever i need to see them or from another phone or client .
    Can anyone help with that please ?
    Thanks

    Hi and Welcome to the Community!
    It all depends on a great many things:
    How exactly is the GMail account integrated to the device? IMAP? POP? EAS?
    How exactly do you have your device configured for deleted item reconciliation? Delete from device only? Delete on both device and server?
    Is there any other client email software running (e.g., Outlook, Thunderbird, etc.) and interfacing with this GMail account? If so, are they perhaps the culprit with this deletion activity?
    Is this the case all the time? Just with some items? It would be quite unusual to have this behavior with only some items...typically, it's "all or nothing".
    Is this deletion from the server happening as the items are synchronizing to your device? Or, is it happening after some other interaction by you with the items?
    Sorry for so many questions, but your post was a bit confusing:
    ahmed_hesham wrote:
    My problem is that i realized that some e-mails of my gmail account are not on web server but are on my phone , yet iam sure i didn't Delete any mails from my Z30 !
    There is no setting that would act this way...if you delete it from your device, then it may or may not delete from the server -- it depends on the settings you have configured on your device. So the wording there is a little bit confusing...
    ahmed_hesham wrote:
    I really need that my BB wouldnt download e-mails and delete them from server , i need them to be on gmail whenever i need to see them or from another phone or client .
    The only time that might happen is with POP...which, IMHO, is a "dead" technology...IMAP and EAS are so much better, and should always be used if available (and, for GMail, IMAP definitely is available, and EAS might be available depending on a number of other circumstances).
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • [Help Needed] - How to Delete autorun.inf?

    In one of my folders, there is this particular file which I cannot delete called "autorun.inf". I have read in some of the forums mentioning that it is a virus. Most of the solutions are meant for PC.
    However, I can't find any solution to delete this from my Macbook Pro.
    For your info - the sharing and permission for this file is for both "Read & Write" but yet I cannot delete it.
    Please help... thanks..

    It's not a virus.
    I have it in with some Windows Parallels stuff.
    If you must delete it (not recommended) try selecting it then pressing command delete.
    Your admin password is needed.
    Thanks ... Ken

  • Help needed for building report with execution method Java Concurrent prog

    Hi,
    I have saw a report like this:
    The report has executable "XML Publisher Data Template Executable", short name as "XDODTEXE", application "XML Publisher",execution method "Java Concurrent program". Also the report has a XML publisher Data Template and Data definition and in the data definition a .xml file is attached.
    I could not understand what is the data source?
    Could anyone help me on how to build or update this type of report?
    Is there any link or help docs which has proper step by step procedure to build this type of xml publisher report?
    Please help.
    Thanks.

    The xml file which is attached to the data definition is the data source and it has sql queries and structure of xml file.
    Check this out for step-by-step guidance.
    http://www.oracle.com/technetwork/middleware/bi-publisher/overview/xmlebsrep-132947.pdf
    http://apps2fusion.com/at/ps/51-prabhakar/262-xml-publisher-and-data-template-sql-query-to-develop-bi-publisher-reports
    For more on data templates refer user guide
    http://download.oracle.com/docs/cd/E10415_01/doc/bi.1013/e12187/T421739T434255.htm

  • Help needed in the Merge Statement

    Hi All,
    I am using MERGE statement in my program. I want to maintain the log for the duplicate reords mean maintain the log for those reocrds which are updated in the merge statement.
    Can any one help me in this that how can i maintain the log?
    Thanks for your help in advance.
    kind Regards,

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:35615502072484

  • Help needed in building a  sql query

    Hello,
    I am using Oracle 10g db.
    I have 3 tables table1 and table2 and table3
    I am writing one sql query which is like
    select table1.a a1,(select distinct b from table2,table3 where table2.id=table3.id and table1.id=table2.id) b1
    from table1
    Now the b1 value may give more then 1 values so when i am trying to execute the query its giving me error.
    What i would like to have is if it gives returns more then 1 value then add that value as a new column means if b1 gives like abc and def as values.
    Then i want the sql to return like
    acolvalue abc def as a single row.
    Is this possible to do?
    Thanks

    Hello,
    The approach which i took is i wrote a function which gives me the b values , sseparated.
    Then i am building a outer query considering the max of b so i just found there are max 10 values which one row is showing.
    select b11,b12,b13,,,b10
    from (
    select table1.a a1,func(select distinct b from table2,table3 where table2.id=table3.id and table1.id=table2.id) b1
    from table1)
    but now i am facing problem like the value of b1 is a,b,c
    i want to use the substr and instr function to get
    a as b11
    b as b12
    c as b13
    can anyone pls help me out to write a query? i am getting b11 but other values are somehow not coming.
    for b11
    i used
    substr(b1,1,instr(b1,',',1,1)-1)
    Thanks

  • Help needed in building a function

    Hello,
    I am using Oracle DB 11g.
    I am writing a function.
    create or replace function func(tab VARCHAR2) RETURN VARCHAR2 AS
    cursor c is SELECT column_name
    FROM all_tab_columns
    WHERE table_name =tab;
    begin
    //some statements
    for i in c loop
    flag=1;
    //some statements
    end loop;
    //use the same c cursor query
    if flag!=1 then
    //repeat the block inside the for loop;
    end if;
    end;
    Function works fine.
    Now once the for loop ends,what i want is if it doesn't enter the for loop, then for just for once enter the if condition for
    any column from the table and repeat the process, which i am doing inside the for loop.
    But here i am finding repetition of same query and the block of code.
    Is there any way i can avoid that?
    Thanks

    How about you start from scratch and explain the business problem you are attempting to solve. Not a portion of a technical implementation that doesn't seem to make any sense.
    Start from the beginning, no code ... just "i have a situation where i need to .... ".
    Should be a lot more productive.

  • Flex 3 :Help needed in implementing View States

    Hi 
    I am new to Flex , i am trying to understand View States , tried for one hour but got confused .
    (Basically by seeing the examples i understood the concept , but failed to implement ) 
    Please help .
    Assume my requirement is at the load of the page , i want to show an Login Button and a Chnage State Button (common button) only .and when the Change State button is clicked on ,i want to show the Register Button .
    So for this i made two Forms , and a common button .
           <mx:Form id="RegForm">
                <mx:Button label="RegFormButton" id="RegFormButton"/>
            </mx:Form>
            <mx:Form id="loginForm">
                        <mx:Button label="LoginButton" id="loginButton"/>
            </mx:Form>
    <!-- A common button for both the States-->
      <mx:Button label="Change State"
                  click=""/>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" currentState="Register">
    <mx:states>
    <mx:State name="Register">         
    <mx:SetProperty   target="RegForm"   value="Register"/>
    </mx:State>
    <mx:State name="loginForm">
    <mx:SetProperty   target="loginForm"   value="Login"/>
    </mx:State>
    </mx:states>
    ( I think some how i can write the Logic to chnage to the current state to loginForm when user clicks with some inline code , but please tell me At the start of the page please tell me why I am not able to show the Register.

    sorry for posting a dumb question .
    I realized my mistake .

Maybe you are looking for

  • [ps3mediaserver][pms-svn][AUR] No sound while using external subtitles

    Greetings everyone, I am experiencing some weird behavior while using External Subtitles, e.g. Playing an AVI file with PS3MediaServer works fine but playing the very same AVI file with external subtitles gives me the video with subtitles and no soun

  • How to build a DLL that has Pascal calling conventions with application builder?

    Hi, I'm researching for possible solution to one of our problems. In one case, solution would be to build a DLL from LabView code. This should be simple task, but the application that is going to load the DLL requires that the functions in the librar

  • EJB QL Sample errors in deploying

    I get following error when deploying ear file in oc4j10g. => D:\oc4j10g\j2ee\home>java -jar admin.jar ormi://localhost:23791 admin welcome -d eploy -file d:\myj2ee\oc4jsamples\accounts\ejbql\build\ejbql.ear -deploymentName Ejbql Error: Deploy error:

  • Macbook Pro and Airport

    I have just purchased a 2.2 GHz Macbook Pro. Love it - but - can't get online with Airport. We have a wireless LInkSys router. The computer controlling the router is a PC. We are using WEP encryption. The router will not let me sign on to the network

  • Trying to use a SAS on a queue to post a message - Cannot successfully construct client

    Using VS 2013, .NET 4.5 target, and WindowsAzureStorageClient from NuGET. I have a use case where I want an application to post messages to a specific queue, but I don't want to give the storage account keys out (obviously). So I thought I would crea