How to get a summ of all previous values

Hello ALL,
Could you please give an advice on how to find the sums of all previous values in 1 select without using dynamic sql. Cross join is not a variant because of a huge response time.
OR may be there are any other ideas on how to find first rows with total sum equals to some general value? My idea is to find a sum of all preceding values and the first of such sums that would be equal to the general value or greater it is a necessary result.
For example we have goods receipts:
MATERIAL | BATCH | QTY
material1 batch1 1
material1 batch2 2
material1 batch3 3
material1 batch4 4
material1 batch5 5
material1 batch6 6
and general qty is 7 - it's our current stock. So I should take material from [batch1 to batch4] to get necessary QTY >=7 (1+2+3+4=10>7) So our current stock consists of batch1,batch2,batch3 and remains of batch4.
Thanks in advance!
Edited by: user9321926 on Jun 18, 2010 3:56 AM

Some thing like:
  1  select
  2     empno,
  3     sal,
  4     (select sum(sal) from emp b where  b.empno <= a.empno) running_total
  5* from (select * from emp order by empno) a
SQL> /
     EMPNO        SAL RUNNING_TOTAL
      7369        800           800
      7499       1600          2400
      7521       1250          3650
      7566       2975          6625
      7654       1250          7875
      7698       2850         10725
      7782       2450         13175
      7788       3000         16175
      7839       5000         21175
      7844       1500         22675
      7876       1100         23775
     EMPNO        SAL RUNNING_TOTAL
      7900        950         24725
      7902       3000         27725
      7934       1300         29025
14 rows selected.
SQL>

Similar Messages

  • How to get warning by using the previous value of the column and new value

    Hi all,
    Suppose the column A has the true and when I click on button which also sets the value of the column as true I should dispaly warning that column a is already true.How can I achieve this.How to store the original value of the column and then check wirth the new value.
    Thanks in advance.

    You dont have to store the value anywhere
    You can do this from setMethod of EOImpl.java
    eg:
    void setAttributeXXX(String Value)
    // value contains new value
    // getAttributeXXX() contains oldValue
    if (value.equals(getAttributeXXX()))
    // Verify value is > 0 if (value.compareTo(0) <= 0)
    throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, // indicates EO source
    getEntityDef().getFullName(), // entity name
    getPrimaryKey(), // entity primary key
    "AttributeXXX", // attribute Name
    value, // bad attribute value
    "AK", // nessage application short name
    "FWK_TBX_T_EMP_SALARY_REQUIRED"); // message name
    setAttributeInternal(AttributeXXX, value);
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • In mdx how to get max date for all employees is it posible shall we use group by in mdx

    in mdx how to get max date for all employees is it posible shall we use group by in mdx
    example
    empno  ename date
    1         hari        12-01-1982
    1         hari        13-06-2000
    by using above data i want to get max data

    Hi Hari3109,
    According to your description, you want to get the max date for the employees, right?
    In your scenario, do you want to get the max date for all the employees or for each employee? In MDX, we have the Max function to achieve your requirement. You can refer to Naveen's link or the link below to see the details.
    http://www.sqldbpros.com/2013/08/get-the-max-date-from-a-cube-using-mdx/
    If this is not what you want, please provide us more information about the structure of you cube, so that we can make further analysis.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How the get an overview of all existing sapscripts ?

    How the get an overview of all existing sapscripts ?
    does someone know ?
    thanks again : )

    Hi David,
    Go to SE71, and press F4 in the Form name tab.There you can view the various Modules, from where in you can get an overview of the all forms related to the corresponding modules.
    SE71 is the transaction for creating customized forms, viewing and making changes to the standard forms by copying them to Z-forms.
       Hope this is helpful to you. If you need further information, revert back.
    Reward all the helpful answers.
    Regards
    Nagaraj T

  • HT1719 My shuffle is not syncing all of the selected songs & I can't figure out how to get it to sync all the checked songs. Please help!

    My shuffle is not syncing all of the selected songs & I can't figure out how to get it to sync all the checked songs (syncs some, but not others). Please help!

    Perhaps this article can help.
    Syncing music to iPod shuffle
    B-rock

  • How to get fourthly row (row4) first column value (col1) in matrix

    Hi to all,
    In FMS, how to get fourthly row (row4) first column value (col1) in matrix in document.
    select $[$38.1.4]
    But it display the first row
    Please give me hint.
    Thank you

    Hi Eric,
    FMS may only apply to current row.  There is no way to get any other fixed row.
    Thanks,
    Gordon

  • How to get or set default fiscal year value in billing doc

    Hi All, my question is simple, how to get or set default fiscal year value (VBRK_GJAHR) in billing document.. is it possible.
    Thanks.
    Regards,
    Michael

    Hi Michel
    If you feel that the fiscal year value should come  in the billing document then you have to use a user exit USEREXIT_NUMBER_RANGE .
    As this is a related to ABAP , you should give the inputs and ABAP'ers will give the number range as per our requirement .
    Regards
    Srinath

  • How to get a unique row in a value set

    How to get a unique row in a value set which is used in concurrent program.
    Example if a table contains 10 unique rows i need only one row to show.
    Thanks

    add conditions in where clause to supress the duplicate values.
    On how to supress the duplicate values follow the link
    http://oracleschools.com/index.php?topic=40.msg76#msg76
    Thanks
    Prudhvi
    www.erpschools.com

  • How to Get a List of All XMLElements (Follow up to previous posting)

    (CS5, Win7, 64Bit)
    I need a collection (or array, etc.) of all the XMLElement objects in a given document in flat form (just like the "Structure Tree"'s hierarchichal view - only flatened).
    I could not find any "normal" way (i.e., built-in property or method) to get at the information. Instead, I found that I had to recurse through the entire XMLElement tree, starting with the Root Element. For a large document, this can take close to a ten minutes, and sometimes I have to do this for an InDesgin Book containing over ten enormous INDD files.
    After "கற்பனை Imagine" responded to my previous post about how to get all the XMLTags, I assumed that myDocument.xmlElements would return a collection of all the XMLElements in the Document. Unfortunately, it does not - it returns only the Root XMLElement. Thus, I have to recurse therough the hierarchy of XMLElements under the Root XMLElement - which takes a very long time.
    There HAS to be a better way, right?
    Would it be better were I to recurse through all PageItems in the document and then recurse through each PageItem's XMLElement tree? I assume that wouldn't make a big difference either way.
    I'm open to suggestions...
    TIA,
    mlavie

    mlavie:
    I could not find any "normal" way (i.e., built-in property or method) to get at the information. Instead, I found that I had to recurse through the entire XMLElement tree, starting with the Root Element. For a large document, this can take close to a ten minutes, and sometimes I have to do this for an InDesgin Book containing over ten enormous INDD files.
    What do you intend to do with this flat layout of XMLElements? That probably matters a great deal.
    If performance is really at play, you can try using XML Rules instead of interacting with the DOM from JavaScript. But they are complicated and confusing and more suited to declarative programming.
    Imagine suggests:
    var a = myroot.evaluateXPathExpression ("//*");
        xmlObjArray.push(a[b--]);
    Why not stop there? evaluateXPathExpression already returns an array, why iterate over it and push its elements into a new array? What's wrong with the return value?

  • How to get the list of all formtypes in SBO?

    Hello,
    How can i get the list of all available formtype in SBO?
    Each SAP Business One form has a unique type to support multiple instances of the same form. For example, the type of the Purchase Order form is 142, Form=139 for Sales Order.
    Is this information stored anywhere?
    Thanks and Regards,
    Sheetal

    Hi Juha / Sheetal,
    Activating the menus will only help to get the forms which are "directly" accessible...
    ...but there are forms that come up only when clicking some button - or double-clicking - or activating a menu item in the (dynamic!) "Goto" menu etc.
    In 2005 SP01 a new function was introduced (and documented in the SDK Helpcenter) that can be used to iterate over all integer IDs (note there are a lot of gaps) up to 65535 and get information about the form and items on it (specifically the databinding!).
    Please take a look at the ResourceData property of the Application object in UI API!
    Gaps (in A version today - to my best knowledge): 10.000 - 20.000; 21.000 - 40.000; 41.000 - 50.000; 51.000 - 60.000...
    Regards,
    Frank
    <i>Visit the WiKi-FAQ at: https://wiki.sdn.sap.com/wiki/display/HOME/BusinessOneFAQ</i>
    BTW: What do you need that information on "all forms" for?
    Message was edited by:
            Frank Moebius

  • How to get the list of all users

    Hi,
    Is there a way in Grid Control for getting the list of all users on all target databases? I need to count how many Oracle db users in our company.
    Thanks a lot.

    One way to do it might be...
    Assuming you have preferred credentials set up for all of your databases, you could run a 'select username from dba_users or all_users;' against all of your databases through grid control.
    Click on Targets tab, click Databases, then the 'Execute SQL' link at the bottom of the page. Click 'Add' and 'Select All'. Then run it. It's just running the same sql across all of your databases and the output will be at the bottom for all of them.

  • How to get the size of all InfoCubes and DSO's?

    Hi all,
    My client wants a complete list of all InfoCubes and DSO's in terms of size (no records but KB). This list of the Cubes / DSO's gives us a picture of the used storage per Area and can be charged. Iu2019ve seen some threats and looked into the possibilities of ST14 and DB02. ST14 provides the ideal list but with a restriction for the top 30 InfoCubes and the top 30 DSO's. Does anyone know how to get such a list for all InfoCubes and DSO's?
    Thnx in advance,
    Henk.

    Hello Henk,
    while I am searching for some performance problems in our BI, I tried to look through the new DB02 of BI 7.0. And there is a function which helps a lot creating lists of Cube, DSOs and so on:
    Start DB02
    On the left side find SPACE -> Additional Functions -> BW Analysis
    A Doubleclick will give you a broad survey of the current memory disposition regarding BI/BW objects.
    In the BW Area "Cubes & related objects" you can find Infocube E- and F-Facttable. Depending on the Compressed state of your cubes you will find more data in E or F. Just doubleclick on one of these Entries. In my environment currently F-Tables are more effective.
    You will then get a list of all Infocubes with size.
    You will have to this for E and F Tables and some up over the Infocubes. But, because this will show only the Cubes and not the partitions of the cube it will be much easier to handle than DB02OLD.
    Perhaps this helps, because you did not mention your BW/BI release.
    Kind regards,
    Jürgen

  • How to get the handle of all text fields in the subforms, using script

    Hi Friends,
    I have around 20 fields in a subform, how can i get the names of all the fields using script.
    I wish to enhance the following script where the field names are hard coded
    thereby the script itself will get the names of the field names.
    var f1 = this.parent.somExpression + ".TextField2" + ",";
    var f2 = f1 + this.parent.somExpression + ".DropDownList1" + ",";
    var f3 = f2 + this.parent.somExpression + ".NumericField1";
    xfa.host.resetData(f3);
    Any help will be greatly appreciated..
    Thanks
    JJ

    Hi Paul,
    Thanks for your comments.
    I achieved the clear contents by resetting, by taking input from your thoughts..
    form1.sub1.sub2.sub3.table_1.addDelete_Top.addDelete.deleteRow::click - (JavaScript, client)
    //Here is my code finally look like..
    //row 1, table_1 are also subforms
    for (var i=1;i<10;i++){
    var myRow = this.resolveNode("table_1.row1[" + i + "]");
    if(myRow.presence == "hidden"){
    i = i-1;
    var myRowDelete = this.resolveNode("table_1.row1[" + i + "]");
    if(i!=0){
    xfa.host.resetData(myRowDelete.somExpression);
    myRowDelete.presence = "hidden";
    break;
    if(i==9){
    xfa.host.resetData(myRow.somExpression);
    myRow.presence = "hidden";
    break;
    Thanks
    JJ

  • How to get firefox to return to previous link and not reload it

    When viewing content from a page in a tab, clicking the back button causes the previous page to reload in stead of just returning to it. That makes it impossible (without opening the info in a new tab) to return to a page and click the next item you want to view because it is no longer there.
    Also, sometimes you get the message that the previous page is not available with a "try again" button.
    I just want the back button to return to the previous page and NOT reload it.
    I'm hoping there's an about:config setting that fixes this.
    Version 32.0.3
    TIA

    In order to change your Firefox Configuration please do the following steps :
    # In the [[Location bar autocomplete|Location bar]], type '''about:config''' and press '''Enter'''. The about:config "''This might void your warranty!''" warning page may appear.
    # Click '''I'll be careful, I promise!''' to continue to the about:config page.
    browser.cache.check_doc_frequency
    Set how often to check accuracy of cached documents
    * 0 : Once per session
    * 1 : Each time
    * 2 : Never
    * 3 : When appropriate/automatically

  • How to get Last Day of a Previous Month

    Hi all,
    I need to get Last Day of the Previous Month. I am able to get Current Month Last Day using Calendar.getActualMaximum(Calendar.DATE)
    But I need previous Month's Last Day.
    Thanks
    Vamshi.

    Thanks all....
    I have been trying the same and could get it.....
    here is the code for that....
    SimpleDateFormat simpleDate = new SimpleDateFormat("MM/dd/yyyy");
    Calendar calendar = Calendar.getInstance();
    month = calendar.get(Calendar.MONTH);
    //year = calendar.get(Calendar.YEAR);
    calendar.set(Calendar.MONTH, month-1);
    calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
    //lastDayOfMonth = calendar.getActualMaximum(Calendar.DATE);
    System.out.Println("Previous Month End Date is :: " + simpleDate.format(calendar.getTime()));
    this works....
    thanks for ur replys....

Maybe you are looking for

  • Duplicates in Library

    I have no idea why, but recently my itunes library just reverted back to a previous date- as in everything I'd added in the past three months was missing, and in my playlists, there's a folder that says "restored playlists". I tried deleting itunes a

  • Registry settings for I-Tunes burner missing

    I have had I-Tunes for several years and have never had a problem before. Recently a start-up message has started opening that says, "The registry settings used by the I-Tunes drivers for importing and burning CDs and DVDs are missing. This can happe

  • Setting Styles in AS3

    Hi, I am trying to set styles on components in AS3 via an external stylesheet because the documentation suggests that using the setStyle method should only be reserved for styles that change at runtime. Quote: A common mistake that impacts performanc

  • Wrong link in xampp wiki [SOLVED]

    The article Under Manual Installation it links to the MS windows version of xampp. Last edited by Mugi (2014-08-22 15:37:38)

  • How to set source in VideoPlayer via actionscript?

    Hi, I'm trying to play video in spark.components.VideoPlayer by setting its source property. However, on playing the video doesn't play and comes out as garbled. Am I missing something here? Here is the source code- <?xml version="1.0" encoding="utf-