The cumulative value of a week getting problem defined by the user

I have a requirement where I have to cumulative values by week where a week is defined as from Sunday to Saturday. For example:
date           value     acc_value          
9/1/2010     2     2          Wed     
9/2/2010     5     7          Thur     
9/3/2010     3     10          Fri     
9/4/2010     4     14          Sat     
9/5/2010     8     8          Sun     value is reset
9/6/2010     2     10          Mon     
9/7/2010     1     11         Tue     
9/8/2010     4     15         Wed     
9/9/2010     7     22         Thu     
9/10/2010     4     26          Fri     
9/11/2010     5     31         Sat     
Any help would be appreciated.

Thank you.

Try this:

with my_table as (select to_date('01/09/2010', 'dd/mm/yyyy') dt, 2 value from dual union all
                  select to_date('02/09/2010', 'dd/mm/yyyy') dt, 5 value from dual union all
                  select to_date('03/09/2010', 'dd/mm/yyyy') dt, 3 value from dual union all
                  select to_date('04/09/2010', 'dd/mm/yyyy') dt, 4 value from dual union all
                  select to_date('05/09/2010', 'dd/mm/yyyy') dt, 8 value from dual union all
                  select to_date('06/09/2010', 'dd/mm/yyyy') dt, 2 value from dual union all
                  select to_date('07/09/2010', 'dd/mm/yyyy') dt, 1 value from dual union all
                  select to_date('08/09/2010', 'dd/mm/yyyy') dt, 4 value from dual union all
                  select to_date('09/09/2010', 'dd/mm/yyyy') dt, 7 value from dual union all
                  select to_date('10/09/2010', 'dd/mm/yyyy') dt, 4 value from dual union all
                  select to_date('11/09/2010', 'dd/mm/yyyy') dt, 5 value from dual)
-- end of mimicking your data in a table called my_table
select dt,
       value,
       sum(value) over (partition by trunc(dt+1, 'iw') order by dt) acc_value,
       to_char(dt, 'dy') dy
from   my_table
order by dt;

DT              VALUE  ACC_VALUE DY
---------- ---------- ---------- ---
01/09/2010          2          2 wed
02/09/2010          5          7 thu
03/09/2010          3         10 fri
04/09/2010          4         14 sat
05/09/2010          8          8 sun
06/09/2010          2         10 mon
07/09/2010          1         11 tue
08/09/2010          4         15 wed
09/09/2010          7         22 thu
10/09/2010          4         26 fri
11/09/2010          5         31 sat

Tags: Database

Similar Questions

  • Problem with pl/sql procedure, trying to get the value of the user during execution

    Hello

    Using oracle 11.2.0.3

    Can run sql that gets the value of the user during the fine workmanship and also via an anonymous block.

    uses of SQL & Enter_Product_Number

    anonymous block using: Enter_Product_number.

    However, get problems when trying to create a pl/sql procedure, use one of the above

    relevant below tried code part & and: buit works do not error, try bad bind variable if used: and ora-600 if try use &.

    How can we have a procedure from pl/sql that can call and receives a value of user during execution?

    Only way around what I can think of is to pass parameters to the procedure

    Thank you

    create or replace procedure ins_into_issues is

    v_nd_rec_cnt number (10);

    v_normal_rec_cnt number (10);

    Start

    Select count (*)

    in v_nd_rec_cnt

    refmast.issues I have

    where i.iss_product_num = & old_nd_product_number;

    Select count (*)

    in v_normal_rec_cnt

    refmast.issues I have

    where i.iss_product_num = & normal_product_number;

    -code below commented above works.

    end;

    Hello

    what something like this:

    create or replace procedure INS_INTO_ISSUES ( in_normal number, in_old number )  is
      v_nd_rec_cnt     number(10);
      v_normal_rec_cnt number(10);
    begin
        select count(*)
          into v_nd_rec_cnt
         from refmast.issues i
         where i.iss_product_num = in_old;
      --
        select count(*)
          into v_normal_rec_cnt
          from refmast.issues i
         where i.iss_product_num = in_normal;
    end;
    

    concerning

    Kay

  • Get the cumulative values in a single column based on another column in reports

    Hi all

    I have a requirement to get cumulative values based on another column.
    I 'Sales rep name' in the first column.
    Correspondent "Values of the invoice line" in the second column.
    Want to have cumulative of all the values for each sales invoice line.
    Then apply rank and display the top 10 sales reps based on invoice lines.
    Since there is no rank option in the PivotTable, I do this in the report table.

    Looking for the best entries...

    Thanks in advance...

    Try below
    2nd column: "name of Sales rep.
    column 2: SUM ("invoice line values ' BY 'Name of Sales rep'") and sort this field desc.
    3rd column: fx RANK (SUM ("invoice line values" BY "Sales rep name")), to hide this column, so that you don't confuse your users.

    and put the filter on the 3rd column below 5

    I hope this works for you

  • I have a HTML5 form that sends a null (%) if the user does not have a choice. It works fine, but I get an error of W3c on the value of '% '. Is there another way to send a NULL value?

    I have an HTML5 form that allows the user to select 1 of 6 provinces of Costa Rica. If they do not select a Province, I use php code to send a NULL value and the other selections research of the form looking for all Provinces. If they choose a province, we are looking for database records that are found in this province.  Currently I use the value = '%' as the selected value if the user does not have a choice. It works and looks in all provinces, but I get an error of W3c checking on the value = '% '. Y at - it another way to send a NULL value. PS: I have the same problem on the following form which allows you to select the Business category. The page is http://www.yellowpagescr.com

    Here is a copy of the code. The RED line works but gets a W3c issue error of the test page. :

    < form = class "navbar-form Center navigation bar" role = "Search" action = "#searchresults" method = "get" name = "selectterms" id = "selectterms" title = "" >

    < select name = "province" autofocus class = 'copyright' title = "Click to select a Province (optional)" >

    < option value = '%' selected = "selected" > all Provinces < / option >

    < option value = "alajuela" > Alajuela < / option >

    < option value = "cartago" > Cartago < / option >

    < option value = "Guanacaste" selected > Guanacaste < / option >

    < option value = "heredia" > Heredia < / option >

    < option value = "Limon" > Limon < / option >

    < option value = "Puntarenas" > Puntarenas < / option >

    < option value = "San Jose" > San Jose < / option >

    < option value = "Other" > other < / option >

    < / select >

    The correct way.

    Nancy O.

  • Why do I get problems with the challenges of poker Facebook poker?

    Why do I get problems with the challenges on facebook poker? have reloaded JAVA.didn't work

    URL of affected sites

    http://

    I'm not sure what that requires the application of poker, but perhaps solutions in the article of problems with some Facebook games, cat and more will help

  • When you receive a text, I always get an alert tone. However, I don't get an alert of a particular iPhone user tone. This user received a warning sound when I have them send a text. Is this a phone w / my problem or the user? Is there a solution?

    When you receive a text, I always get an alert tone. However, I don't get an alert of a particular iPhone user tone. This user received a warning sound when I have them send a text. Is this a phone w / my problem or the user? Is there a solution?

    Hi royster677,

    Thank you for using communities Support from Apple! I'm sorry to hear that you are having these problems with your iPhone. If you are having problems with the tone of the text for a specific user, you can check the parameters of Contact of the user (under the Edit button) as shown in the following page of the User Guide:

    Contacts at a glance - iPhone

    If everything looks correct, and you still have questions, you can also check your settings stuck and do not disturb:

    Block calls and messages to block or filter on your iPhone, iPad or iPod touch - Apple Support

    Use of do not disturb on your iPhone, iPad or iPod touch - Apple Support

    Concerning

  • Error message "the service user profile Service has no logon. Unable to load the user profile"How can we get in the laptpop to solve the problem? /

    We get the error message "the service user profile Service does not logon, user profile cannot be loaded."  Prevents us from entering the computer laptop-so how to solve this problem?  Help?

    Hi LisaPie,

    Step 1: You can run the fixit available in the article below

    Error message when you log a computer Windows Vista-based or Windows 7 by using a temporary profile: "the user profile Service has no logon. Unable to load the user profile.
    http://support.Microsoft.com/kb/947215

    Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base:

    How to back up and restore the registry in Windows
    http://support.Microsoft.com/kb/322756/

    If you cannot start the computer in normal mode, try the steps in safe mode with networking

    Step 2: Start the computer in safe mode with network. To do this, follow the steps below:

    Access the menu advanced startup options by turning on your computer and pressing the button F8 before Windows starts. Advanced startup options menu select SafeMode with networking

    http://Windows.Microsoft.com/en-us/Windows-Vista/advanced-startup-options-including-safe-mode

    Thank you, and in what concerns:

    Ajay K

    Microsoft Answers Support Engineer

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • I also, I get the error "the service user profile Service has no connection, failed to load the user profile" but I have not been able to correct the problem by following the listed solutions.

    I got the error "the service user profile Service has no connection, failed to load the user profile" when you try to use my desktip.  It is on the login page.  My account icon loads and the guest account. I have enter my password as an administrator and get the error message listed above. I followed all the solutions I could find and it is not corrected.

    I have a slight hitch, after several failed here, I checked the domestic Group on my laptop and I have high listed as connected to the Group Home Office; with all the files.  How can I fix the desk top to coinside with his status of being online.  Yet once, my counter top will not recognize the password, but the desk top shows online in the home group.

    Home Group is Windows 7.

    Here is the Vista Forums.

    What operating system do you use?

    Vista info below:

    ·                        Restore point:

    Try typing F8 at startup and in the list of Boot selections, select Mode safe using ARROW top to go there > and then press ENTER.

    Try a restore of the system once, to choose a Restore Point prior to your problem...

    Click Start > programs > Accessories > system tools > system restore > choose another time > next > etc.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    If the above does not work:

    ·                        http://www.Vistax64.com/tutorials/130095-user-profile-service-failed-logon-user-profile-cannot-loaded.html

    See if the information in the above tutorial will help you.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    http://windowshelp.Microsoft.com/Windows/en-AU/help/769495bf-035C-4764-A538-c9b05c22001e1033.mspx

    Difficulty of a corrupted user profile

    After creating the profile, you can copy the files from the existing profile. You must have at least three user accounts on the computer to perform these operations, including the new account that you created.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    http://support.Microsoft.com/kb/947242

    A temporary profile is loaded after you connect to a Windows Vista-based system

    See you soon.

    Mick Murphy - Microsoft partner

  • Get the field to remain Virgin until the user enters the value in the previous field used in the calculation

    I work on a PDF form and am stuck on one of my calculations. There are two fields 'desired Start Date", which is a date entered by the user. The "desired end" date is one year from date entered by the user. I figured out - however, before the user enters a date, I want this field remains empty. Currently, it fills with 01/00/000. How can I get this field to calculate not unless a date is entered by the user? So far, I tried this but can not get the blank to stay:

    If the field 'Desired Start Date' is empty, leave 'to' field blank

    var myStartDate = new Date (this.getField("Desired_Effective_Date").value);

    If (((myStartDate == 0) & & (getField("myStartDate").valueAsString = "")) {event.value = "";})

    If the field "Desired Start Date" is an effective date, use the date to calculate one year after the date of entry.

    }

    else {this.getField("to").value = util.printd ("mm/dd/yyyy", new Date (myStartDate.getFullYear () + 1, myStartDate.getMonth (), myStartDate.getDate ()))}

    Try the following than the calculation script custom field "to".

    Get the value of the date field beginning

    var sStartDate = getField("Desired_Effective_Date").valueAsString;

    If the start date field is not empty...

    If {(sStartDate)

    Converts a date in a date object string

    Kai = util.scand ("mm/dd/yyyy", sStartDate);

    Add a year

    oDate.setFullYear (oDate.getFullYear () + 1);

    Set this field to the calculated date value

    Event.Value = util.printd ("mm/dd/yyyy", anyway);

    } else {}

    This field blank because the input field is empty

    Event.Value = "";

    }

    You may need to change the date format "mm/dd/yyyy", I used to match the formats of date fields.

  • Get the value of the user in plsql environment

    Hi all

    I am writing a program like below:

    DECLARE

    v_user VARCHAR2 (10);

    v_pswd VARCHAR2 (4);

    v_cardN VARCHAR2 (5);

    v_authState BOOLEAN;

    v_choice NUMBER;

    BEGIN

    DBMS_OUTPUT. Put_line ("Welcome to the Bank! Enter your 5-digit card number ");"

    v_cardN: = '& Card_Number';

    v_user: = "& username ';"

    v_pswd: = "& PIN";

    v_authState: = Authenticate_user (v_cardN, v_user, v_pswd);

    IF this is v_authState THEN

    DBMS_OUTPUT. Put_line ("failed authentication! Please re - enter your details).

    GOTO end_line;

    ON THE OTHER

    DBMS_OUTPUT. Put_line (' authentication successful!) Welcome ' | v_user);

    -ATM_Operation();

    END IF;

    DBMS_OUTPUT. Put_line (' what do you want to run');

    DBMS_OUTPUT. PUT_LINE(' 1.) Balance inquiry '. CHR (10) | "2 remove ' | CHR (10) | "3 deposit '. CHR (10) | ("4 check last three Transactions ');

    v_choice: = & choice;

    < < end_line > >

    NULL;

    END;

    /

    Enter the value of card_number: 12347

    Enter the user name: Himanshu

    Enter the value for the PIN: 1234

    Enter the value of the choice: 3

    Welcome to the Bank! Enter your 5-digit card number

    Authentication failed! Please enter your details

    PL/SQL procedure successfully completed.

    It's getting all values quoted with & < variable > got guest quickly even if requested subsequently.

    What is my requirement is: I want the value that arises only when it is requested in order. As choice is requested only after successful authentication.

    Have we not all features in plsql done for user input in this way.

    Please let me know is there within language plsql or not? Or it is possible by taking help of coding code plsql with unix environment or java to achieve?

    It's getting all values quoted with & got invites quickly even if requested subsequently.

    Of course they are! SQL * more is a client tool. It will be:

    1 parse the input

    2. ask all THE required values

    3 replace the values by the user entry in the code

    4. present the code for execution

    5. display the results.

    The code runs on the server and the server has NO contact with the user.

    What is my requirement is: I want the value that arises only when it is requested in order. As choice is requested only after successful authentication.

    Then, you will need to write a client application that will ask at your leisure. Write a Java application to do and then use JDBC to send code or queries to the database.

    Have we not all features in plsql done for user input in this way.

    No - PL/SQL runs on the server. The server has NO contact or interaction with the user.

  • to change the pl/sql block to get the value of the user

    In this code rather than affect the value of the SID in the block, I want to get the sid of the user.

    Help, please.

    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    AMT for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production

    declare

    v_sname t1.sname%type;

    v_issue_date t3.issue_date%type;

    v_book_title t2.book_title%type;

    v_book_id t2.book_id%type;

    cursor c1 is

    Select t1.sname, t3.issue_date, t2.book_title, book_id

    join T1 T3

    using (SID)

    Join t2

    using (book_id)

    where sid = 1;

    Start

    Open c1

    loop

    dbms_output.put_line (v_sname |) » '  || v_issue_date | » '  || v_book_title | ' ' || v_book_id);

    extract the c1 in v_sname, v_issue_date, v_book_title, v_book_id;

    When exit c1% notfound;

    end loop;

    Close c1;

    end;

    /

    Thank you

    If I set up a script that I want to pass a value, I just a configuration variable and name it and use it very similar to a procedure or function. Makes it easy to implement a procedure/function, or to convert a function/procedure in a PL/SQL block for test/debugging with relatively few changes to the code inside:

    declare
       in_sid  number  := to_number('&1');
    
       v_sname t1.sname%type;
       v_issue_date t3.issue_date%type;
       v_book_title t2.book_title%type;
       v_book_id t2.book_id%type;
       cursor c1 is
          select t1.sname, t3.issue_date, t2.book_title, book_id
          from t1 join t3
          using(sid)
          join t2
          using(book_id)
          where sid=in_sid;
    begin
       open c1
       loop
          dbms_output.put_line( v_sname ||' '  || v_issue_date ||' '  || v_book_title || ' ' || v_book_id);
          fetch c1 into v_sname, v_issue_date, v_book_title, v_book_id;
          exit when c1%notfound;
       end loop;
       close c1;
    end;
    /
    
  • The search filter - how to get the value of the metadata entered by the user

    Hello

    I wrote a fixUpAndValidateQuery filter where I want to modify search QueryText.

    I tried to update some of the metadata values entered by the user and then let the fire search query.
    But I'm unable to get the values of metadata user has entered in my java code filter.
    I'm getting like below

    DocType string = binder.getLocal ("dDocType");

    It returns the value "no" even if the user gives the value of the Doctype in the search engine.

    Am I missing something here?

    Kind regards
    Rajendra

    Search filters tend to manipulate the query that ends up being called by the search service. If this isn't what you're trying to accomplish there are probably better filters for you before the actual query is run or after the query is executed.

    If you really need a connection of database at the moment and you can't find a better filter for what you're trying to do that has a database connection, you can always create one like:

    final Provider dbProvider = Providers.getProvider("SystemDatabase");
    final Workspace myWorkspace = (Workspace) dbProvider.getProvider();
    

    Warning: If configure you your own db connection for a filter where no database connection is available, you will need TO release the connection too.

    myWorkspace.releaseConnection();
    

    Published by: fscherpe on February 16, 2011 06:07

  • HW 2 get the value to select only one option selected by the user in the bean support

    IAM using the select only one option button that is filled during execution.

    I want to get the value selected by the user of a choice selection in the bean to support for other operations of... .IAM using this method, but I got a null pointer exception.

    Public Sub test (ValueChangeEvent tokenChange)
    {
    Integer tokenIndex = (Integer) tokenChange.getNewValue ();
    DCIteratorBinding tokenListIter is getBindings1 () .findIteratorBinding ("TokenIDVOIterator");. in this line null pointer exception
    Token of the line = tokenListIter.getRowAtRangeIndex (tokenIndex.intValue ());
    currenttoken = (Number) token.getAttribute ("TokenId");
    System.out.println ("token ID selected:" + currenttoken);

    }

    I want to know if there is any method to get the value of the value selected by the user to select a choice...

    pls help? //

    3 words:

    "research on the forum.

    asked and answered countless times.

  • Getting the values for the attributes of the user in IOM

    Hello

    I have it here is the snippet of code that retrieves the values for all the attributes user OIM 11g. But this code returns the exception of null pointer for attributes with null values. I also put if condition to check for null pointer exception, but always the null value is thrown in the newspapers whenever this code snippet is executed in the event handler.

    Any thoughts?

    private Map getUser(String userKey) {
      Map users = new HashMap();
      User user = null;
      UserManager userManager = (UserManager) Platform
      .getService(UserManager.class);
      try {
      user = userManager.getDetails(userKey, null, false);
      logger.log(ODLLevel.FINE, "User: {0}",new Object[] { user });
    
      } catch (NoSuchUserException e) {
      logger.log(ODLLevel.ERROR, e.getMessage(), e);
      } catch (UserLookupException e) {
      logger.log(ODLLevel.ERROR, e.getMessage(), e);
      }
      Set AttrNames = user.getAttributeNames();
      logger.log(ODLLevel.FINE, "User Attributes: {0}",new Object[] { AttrNames });
    
      Iterator itr = AttrNames.iterator();
      while (itr.hasNext()) {
      try {
      String AttrNAme = itr.next().toString();
      logger.log(ODLLevel.FINE,"Current Attribute is : {0}::",new Object[]{AttrNAme});
      if( user.getAttribute(AttrNAme).toString()!=null && user.getAttribute(AttrNAme).toString().length()!=0){
      String AttrValue = user.getAttribute(AttrNAme).toString();
      logger.log(ODLLevel.FINE,"Attribute: {0} and Value: {1}",new Object[]{AttrNAme,AttrValue});
      users.put(AttrNAme, AttrValue);
      }
      } catch (Exception e) {
      logger.log(ODLLevel.ERROR, e.getMessage(), e);
      }
      }
      return users;
      }
    

    TIA

    A call to ToString on null will give you the exception. You should check that the value is not null before calling toString() on it.

    In addition, you must perform an additional control on the user object that you receive after your try catch block. If the user object is null, then there is no need to run code on the user object.

  • To get the value from the user input

    Hi guys,.

    I have a .sql file, I need to get the feedback from the user and date to treat more end passing as a parameter in the procedure

    test. SQL

    Proc_process (p_in = > lv_in p1_in = > lv_in1);

    Once the process described above is then ask the user to change the table with the name of columnn like col_1

    Press on Y to continue or N to exit

    ALTER table T1 add col_1 date;

    I want these operations to be performed when run test.sql

    Hello

    Maybe something like that

    accept option_1 char prompt 'Do you want to alter table T1 ? ( press y to continue n to skip ) : ' default n
    accept option_2 char prompt 'Do you want to alter table T2 ? ( press y to continue n to skip ) : ' default n
    
    prompt alter table T1 : &option_1
    prompt alter table T2 : &option_2
    
    BEGIN
      --
      IF upper('&option_1') = 'Y'
      THEN
          DBMS_OUTPUT.PUT_LINE('>>>>>>>>>>> ALTER TABLE T1');
      END IF;
      --
      IF upper('&option_2') = 'Y'
      THEN
          DBMS_OUTPUT.PUT_LINE('>>>>>>>>>>> ALTER TABLE T2');
      END IF;
    END;
    /
    
    undef option_1
    undef option_2
    
    prompt @d:\temp\test_accept_2.sql
    

    concerning

    Kay

Maybe you are looking for