How to group these values month by month ?

Hi,
I have a nice SQL statement which returns days by days, the values of a device.
WITH S1 AS
  (SELECT DATE1,
    ROUND(AVG(VALEUR),2) Debit
     FROM EVV_E032
    WHERE DATE1 BETWEEN TO_DATE('01012006000000', 'DDMMYYYYHH24MISS') AND TO_DATE('31122006235959', 'DDMMYYYYHH24MISS')
  AND CLEF_VAR =
    (SELECT CLEF_VAR FROM SITE_DEBIT_RIVIERE WHERE SITE = 'E032'
GROUP BY date1
SELECT NULL LINK    ,
  TO_CHAR(n, 'DD.MM'),
  NVL(ROUND(AVG(Debit),2), 0) "Débit"
   FROM
  (SELECT TRUNC(TRUNC(to_date(2006,'YYYY'),'year'), 'DD')-1 + level n,
    rownum jours
     FROM dual CONNECT BY level<=366
  ) days
LEFT JOIN s1
     ON days.n = TRUNC(date1,'DD')
GROUP BY n
ORDER BY nSample values :
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('10/02/2006 09:49:59','DD/MM/YYYY HH24:MI:SS') 1,63);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('21/02/2006 10:35:12','DD/MM/YYYY HH24:MI:SS') 1,68);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('21/02/2006 11:30:30','DD/MM/YYYY HH24:MI:SS') 0);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('23/02/2006 14:02:02','DD/MM/YYYY HH24:MI:SS') 0);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('23/02/2006 16:22:34','DD/MM/YYYY HH24:MI:SS') 0);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('30/04/2006 18:09:08','DD/MM/YYYY HH24:MI:SS') 1,72);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('20/05/2006 11:57:02','DD/MM/YYYY HH24:MI:SS') 1,72);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('07/06/2006 15:11:58','DD/MM/YYYY HH24:MI:SS') 1,79);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('08/06/2006 20:00:26','DD/MM/YYYY HH24:MI:SS') 1,82);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('19/06/2006 09:42:32','DD/MM/YYYY HH24:MI:SS') 1,72);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('20/06/2006 04:30:00','DD/MM/YYYY HH24:MI:SS') 1,82);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('20/06/2006 10:39:01','DD/MM/YYYY HH24:MI:SS') 1,72);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('24/06/2006 19:34:50','DD/MM/YYYY HH24:MI:SS') 1,82);
Insert into "EVV_E032" (DATE1,DEBIT) values (to_date('26/06/2006 14:37:26','DD/MM/YYYY HH24:MI:SS') 1,88);The output are values grouped day by day. I would like to group tehse values month by month, but could not figure how to do. Even though I am not a newbie newbie on SQL, this code is going far too much for me. I know some of you guys can handle this. I tried hard but coud not succeed. Could you help me ?
Regards, Christian.

Difficult to work out (read: too much hassle) with your data and sql, as you haven't provided a set of info for all the tables provided, but hopefully this will give you an idea:
with my_tab as (select trunc(sysdate)+30 dt, 1 val from dual union all
                select trunc(sysdate) dt, 2 val from dual union all
                select trunc(sysdate) dt, 20 val from dual union all
                select trunc(sysdate)+30 dt, 10 val from dual union all
                select trunc(sysdate)+60 dt, 6 val from dual)
-- end of mockup of table "my_tab"; see SQL below...
select trunc(dt, 'mm') dt, sum(val)
from   my_tab
group by trunc(dt, 'mm')
order by trunc(dt, 'mm');
DT          SUM(VAL)
01-MAR-09         22
01-APR-09         11
01-MAY-09          6

Similar Messages

  • How to find these values fall in what time?

    Post Author: newcruser
    CA Forum: General
    From 9 AM to 5 PM time range..how to find these values fall where?.
    Is that done using group selection method?.  Please give me idea and direction
    UserId   Type      login                               logout1           1          2008-04-13 09:30:42         2008-04-13 10:30:122           2          2008-04-13 09:30:12         2008-04-13 11:00:323           1          2008-04-13 10:30:32         2008-04-13 12:56:234           2          2008-04-13 10:30:42         2008-04-13 12:00:345           2          2008-04-13 11:30:34         2008-04-13 13:40:236           1          2008-04-13 12:30:43         2008-04-13 13:00:437           1          2008-04-13 13:20:43         2008-04-13 14:45:218           2          2008-04-13 14:30:42         2008-04-13 15:15:599           1          2008-04-13 15:00:42         2008-04-13 16:30:4210         1          2008-04-13 16:20:42         2008-04-13 17:00:00

    Post Author: newcruser
    CA Forum: General
    In my case minimum (login) time changes and maximum(logout) time changes everyday.
    I want to create from minimum (login) to  maximum(logout) for every hour, how many people are online. How to do?.
    UserId          login                               logout1           2008-04-13 09:30:42         2008-04-13 10:30:122           2008-04-13 09:30:12         2008-04-13 11:00:323           2008-04-13 10:30:32         2008-04-13 12:56:234           2008-04-13 10:30:42         2008-04-13 12:00:345           2008-04-13 11:30:34         2008-04-13 13:40:236           2008-04-13 12:30:43         2008-04-13 13:00:437           2008-04-13 13:20:43         2008-04-13 14:45:218           2008-04-13 14:30:42         2008-04-13 15:15:599           2008-04-13 15:00:42         2008-04-13 16:30:4210         2008-04-13 16:20:42         2008-04-13 17:00:00
    i found minimum (login) and maximum(logout) using below formula. Now i want to find every hour from minimum (login) to maximum(logout) , so i can use each hour value in formula to calculate how many people are online for that particular time. How to do that?.
    @Minimum
    DatePart("h",(Minimum ()))
    @Maximum
    DatePart("h",(Maximum()))

  • How to get these values?

    This sample output of trcsess shows the consolidation of traces for a particular
    session. In the following example the session index and serial number equals 21.2371.
    trcsess session=21.2371My question is: what are session index and serial number here? How to get these values?

    As per the tuning doc:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/sqltrace.htm#i20110
    You get these values from the V$SESSION view.
    Session Index = SID
    Serial number = SERIAL#

  • How to distribute annual value to each month

    Hi,
    In my case planning is done annually and Key Fig is 0BALANCE. Now once the planning is done:
    1. How do I distribute this annual amount equally in 12 months to Key Figure 0SALES for each month?
    2. How can I have seasonal distribution of this annual amount over whole year posting each month value to 0SALES for respective month?
    Thanks,
    sam

    Hi,
    what do you mean by not understanding part 2?
    Did you ever look at the function?
    I Think it is very self explaining.
    What is your question in detail?
    by the way - I mixed up the first formula, of course it is 0sales = 0balance if you have planned 0balance first.
    and what do you mean by having costcenter and costcentergroup? are these char not filled for 0balance?
    as long as the same char are filled for 0balance and they are included in the aggr level where you do the "copy" to the 0sales figure, they will be filled with exactly the same values as they were before.
    the same applies for the distribution funtion.
    In all planning functions you only have to take care of the fields that are changing and that is in the formula only the key figure and in the distribution funtion only the period.
    Cornelia

  • How to set dynamic value for field Month when running background job ?

    Dear guys,
    I have a Z* report in our company, in the selection screen there is a period field (Month and Year) and this report running in background job periodically. My Question is how i can set for Month field become dynamic follow month value of date when this report executed ?
    Example :
    When Z* report running in background on 16.04.2008, Month Value will be 04 and when running on 16.05.2008, Month Value will be 05.
    Please advice.
    Regards
    Gunawan

    Dear guys,
    I have a Z* report in our company, in the selection screen there is a period field (Month and Year) and this report running in background job periodically. My Question is how i can set for Month field become dynamic follow month value of date when this report executed ?
    Example :
    When Z* report running in background on 16.04.2008, Month Value will be 04 and when running on 16.05.2008, Month Value will be 05.
    Please advice.
    Regards
    Gunawan

  • How to sum time values sorted by month/year?

    I would like to sum time values that are sorted by month/year. (Concept is based on a pilot's logbook)
    In Table 1, Column A is a date; Column B is the associated time value (duration).
    In Table 2, I would like to Sum the time value of Table 1 Column B by month an year.
    TABLE 1
    Date
    Time
    Header 3
    Jan 1, 2013
    2:30
    Jan 3, 2013
    4:15
    Jan 9, 2013
    3:55
    Feb 2, 2013
    5:01
    Feb 10, 2013
    1:33
    March 3, 2013
    5:55
    TABLE 2
    Month/YR
    Total Time
    Header 3
    Jan-13
    10:40
    Feb-13
    6:34
    Mar-13
    5:55
    Apr-13

    smash,
    Here's an example of what can be done:
    The formula in the Total column of Summary is:
    =SUMIFS(Log :: B, Log :: A, ">="&A, Log :: A, "<"&EOMONTH(A, 0)+1)
    The Month column of Summary is filled with a series of dates that can be formatted as Jan-13, etc, if you wish.
    I used the 0h 0m format for the Durations to distinguish it from times.
    Jerry

  • How to Group itab values....

    Hi Experts,
    I have created  a report and inserted into itab. The values are
    Matkl      Pend.Qty.  Pend Value.
    =========================
    SPG           5              100.00
    SPG          3               300.00
    SRG          2              300.00
    SRG          7              800.00
    Now i want to group matkl and total of Pendqty & value into another table.
    How to do that.
    Pl. give some idea.
    Yusuf

    HI,
    DATA: itab type table of <your table> with key MATKL.
    Now use.
    COLLECT wa into ITAB.
    COLLECT sums up all the numeric fields of the table if the KEY's of the records are same.
    SO when push a WOrkarea into a table using PUSH if there exists a record with the key it just adds the value that is there in the workarea to the record.
    Example:
    DATA: BEGIN OF seats,
            carrid   TYPE sflight-carrid,
            connid   TYPE sflight-connid,
            seatsocc TYPE sflight-seatsocc,
          END OF seats.
    DATA seats_tab LIKE HASHED TABLE OF seats
                   WITH UNIQUE KEY carrid connid.
    SELECT carrid connid seatsocc
           FROM sflight
           INTO seats.
      COLLECT seats INTO seats_tab.
    ENDSELECT.
    Regards,
    Sesh

  • How to group the values with this partition over clause ?

    Hi,
    I have a nice request :
    select  c.libelle "Activité", sum(b.duree) "Durée"
    from    fiche a, activite_faite b,
            activites c, agent d
    where   a.date_activite
    BETWEEN TO_DATE('20/09/2009', 'DD/MM/YYYY') AND TO_DATE('26/10/2009', 'DD/MM/YYYY')
    AND     a.agent_id = 104
    AND     a.fiche_id = b.fiche_id
    AND     b.activites_id = c.activites_id
    AND     a.agent_id = d.agent_id
    group   by c.libelle
    order   by sum(b.duree)It gives me this nice result :
    ACTIVITE  DUREE
         Tonte            27I want to get a percentage, i use ratio_to_report
    select  a.fiche_id, c.libelle "Activité", ratio_to_report(duree) over (partition by c.activites_id) * 100 "Durée"
    from    fiche a, activite_faite b,
            activites c, agent d
    where   a.date_activite
    BETWEEN TO_DATE('20/09/2009', 'DD/MM/YYYY') AND TO_DATE('26/10/2009', 'DD/MM/YYYY')
    AND     a.agent_id = 104
    AND     a.fiche_id = b.fiche_id
    AND     b.activites_id = c.activites_id
    AND     a.agent_id = d.agent_idIt gives me this less nice result :
    Tonte 7,40740740740740740740740740740740740741
    Tonte 33,33333333333333333333333333333333333333
    Tonte 33,33333333333333333333333333333333333333
    Tonte 25,92592592592592592592592592592592592593I would like to get this result :
    Tonte 100I tried "grouping" values in the partition over clause but without success.
    Any help appreciated from the slq-masters :
    Regards,
    Christian

    Christian from France wrote:
    I would like to get this result :
    Tonte 100
    Hi,
    Why not this
    select  c.libelle "Activité", 100 "Durée"
    from    fiche a, activite_faite b,
            activites c, agent d
    where   a.date_activite
    BETWEEN TO_DATE('20/09/2009', 'DD/MM/YYYY') AND TO_DATE('26/10/2009', 'DD/MM/YYYY')
    AND     a.agent_id = 104
    AND     a.fiche_id = b.fiche_id
    AND     b.activites_id = c.activites_id
    AND     a.agent_id = d.agent_id
    group   by c.libelle
    order   by sum(b.duree)Because it would always be 100 (if you are taking as percentage) be what ever the count of duree be.
    Or did I miss something in understanding the requirement.
    Regards
    Anurag

  • How to group similar values using XQuery

    I have a table Employee with following columns
    EmpNo number,
    Title varchar2(100),
    First_Name varchar2(100),
    Last_Name varchar2(100),
    1, Miss, A, B (Sample record in Employee Table)
    There is an audit table Employee_A with columns
    ID number (PK),
    EmpNo number,
    Field_Name varchar2(100),
    Old_Value varchar2(100),
    New_Value varchar2(100)
    An update statement causes the Title of EmpNo=1 to change from Miss to Mrs and Last_Name from B to C. Hence the audit table has two records
    1,1,Title, Miss,Mrs
    2,1,Last_Name, B, C
    I need to generate an xml which is as follows:
    <Tag>
    <Operation>Update</Operation>
    <Key>1</Key>
    <Data>
    <Field>
    <Column>Title</Column>
    <NewValue>Mrs</NewValue>
    </Field>
    <Field>
    <Column>Last_Name</Column>
    <NewValue>C</NewValue>
    </Field>
    <Data>
    </Tag>
    How can we do this using XQuery?
    If not, can we do this using xmlelement, xmlagg?

    I tried the following:
    SELECT XMLQuery('<Dummy>
    {for $c in ora:view("Employee"),
               $ca in ora:view("Employee_A")
           let $emp := $c/ROW/EMPNO/text(),
               $emp_a := $ca/ROW/EMPNO/text(),
               $field := $ca/ROW/FIELD_NAME/text(),
               $new := $ca/ROW/NEW_VALUE/text()
               where $emp = $emp_a
           return
           <Tag>
             <operation>Update</operation>
             <key_id>$emp_a</key_id>
             <Data>
             <Field>
               <Column>{$field}</ent_id>
    <NewValue>{$new}</NewValue>
    </Field>
    </Data>
    </Tag>
    }</Dummy' RETURNING CONTENT)
    FROM dual;
    The output that I'm getting is
    <Dummy
    <Tag>
    <Operation>Update</Operation>
    <Key>1</Key>
    <Data>
    <Field>
    <Column>Title</Column>
    <NewValue>Mrs</NewValue>
    </Field>
    <Data>
    </Tag>
    <Tag>
    <Operation>Update</Operation>
    <Key>1</Key>
    <Data>
    <Field>
    <Column>Last_Name</Column>
    <NewValue>C</NewValue>
    </Field>
    <Data>
    </Tag>
    </Dummy>
    Two <Tag></Tag> gets created - one for each update entry. Please help

  • Shift value of the month

    Hi all!
    Our client requirment is dividing Year into 2 parts
    We have substitution variable &CurrMonth="Jan" and we need make calculations in the next way
    Fix(&CurrMonth:&CurrMonth+3 month)
    one type of culculations
    enfix
    Fix(CurrMonth+3 month:EndofaYear)
    another type of culculations
    enfix
    Does anybody know how can I shift value of the month?
    How can I get &CurrMonth+3 month?
    Regards
    Sasha

    I realized that I need 3 Substitution variables
    &CurrMonth
    &CurrMonth+3
    and &CurrMonth+4
    because I should divided Year in 2 parts and variable &CurrMonth+3 included in all of them
    Fix(&CurrMonth:&CurrMonth+3 month)
    one type of culculations
    enfix
    Fix(CurrMonth+4 month:EndofaYear)
    another type of culculations
    enfix
    Can you tell how can I change my substitution variables automaticaly?
    Edited by: Softperson on 14/7/2009 11:20

  • How to get a value from JavaScript

    How to get return value from Java Script and catch it in c++ code. I have tried following code, but its not working in my case.
    what I want is if it returns true then call some function if it returns false then do nothing, so how to get those values in c++
    ScriptData::ScriptDataType fDataType = resultData.GetType();
    if (fDataType == kTrue)
           CAlert::InformationAlert("sucess");
           //call some function
                        else
                                  CAlert::InformationAlert("Error");
         // do nothing
    JavaScript Code:
        if(app.scriptArgs.isDefined("paramkeyname1"))
               var value = app.scriptArgs.get("paramkeyname1");
               alert(value);
                return true;
      else
               alert ("SORRY");
               return false;

    How to get java script result into JSResult i m not getting it.
    I have wriiten follwing code in c++ :
              WideString scriptPath("\\InDesign\\Source1.jsx");
              IDFile scriptFile(scriptPath);
              InterfacePtr<IScriptRunner>scriptRunner(Utils<IScriptUtils>()->QueryScriptRunner(scriptFi le));
              if(scriptRunner)
                        ScriptRecordData arguments;
                        ScriptIDValuePair arg;
                        ScriptID aID;
                        ScriptData script(scriptFile);
                        ScriptData resultData;
                        PMString errorString;
                        KeyValuePair<ScriptID,ScriptData> ScriptIDValuePair(aID,script);
                        arguments.push_back(ScriptIDValuePair);
                        PMString paramkeyname1;
                        Utils<IScriptArgs>()->Save();
                        Utils<IScriptArgs>()->Set("paramkeyname1",scriptPath);
                        Utils<IScriptUtils>()->DispatchScriptRunner(scriptRunner,script,arguments,resultData,erro rString,kFalse);
                        Utils<IScriptArgs>()->Restore();
                        ScriptData::ScriptDataType fDataType = resultData.GetType(); // here i should get true or false which i m passing it from javascript code......not as s_boolean
                        if (fDataType == kTrue)
                                       //CAlert::InformationAlert("sucess");
                                     iOrigActionComponent->DoAction(ac, actionID, mousePoint, widget);
                        else
                                    this->PreProcess(PMString(kCstAFltAboutBoxStringKey));
    Java script code:
    function main()
           var scrpt_var;
           var scriptPath,scrptMsg;
           var frntDoc=app.documents[0];
           if(app.scriptArgs.isDefined("paramkeyname1"))
               var value = app.scriptArgs.get("paramkeyname1");
                alert(value);
                 return true; // i want this value i should get in c++ code...How to get these values in c++
           else
              alert ("Error");
              return false; // i want this value i should get in c++ code...How to get these values in c++

  • How to get  the values of bdcmsgcoll to be printed in report

    hi experts,
    I am updating Va02 using BDc .. this is done however  i m struck at this point..
    I want to display the log i.e  messages  like data was updated ,, or any error ...
    As far as i know these logs are stored in BDcmsgcoll but how to get these value to be
    displayed in report once the update is done ..
    please help..if any body has any code .. then do send it to me.
    Thanks in Advance
    Srinivas

    Srinivas,
    data: messtab type table of BDCMSGCOLL with header line.
    Call transaction 'SM50' using bdcdata
                                  mode 'N'
                                  <b>messages in messtab</b>.
    Loop at messtab .
      write : messtab
    endloop.
    Pls. reward if useful

  • How to display(binding) values in the table from more than one node?

    Hi,
    I have two nodes (TRIPS & AMOUNTS)in the context. How to bind these values into the table control?
    When i bind second one, first one is getting replaced.

    Hi Mog,
    Of course it is possible to create a table from attributes of more than one node, and in some cases this is still necessary, but you have to do this the hard (manual) way.
    If you have a table control, have a look at the properties and the elements belonging to it.
    First of all, there is the property "dataSource", which binds to a multiple node (let's name it TableRootNode). This means that for each element of THIS node, one row is created. In each row the data of exactly one element of this TableRootNode is displayed.
    Then you have columns in this table. Inside of the columns there is a header and an editor. The editor is the interesting part.
    Normally the primary property of this editor is bound to an attribute of the TableRootNode. Then everything works as expected. If it binds to an attribute of a subnode (SUB) of TableRootNode, then in row i the data of the subnode of the i-th element of TableRootNode is displayed. There is no need for SUB to be a multiple node, but it must not be a singleton.
    If you bind a property of the editor to an attribute, which does not lie in the subtree of TableRootNode, then you will see the same value in each row.
    Now it depends on the structure of your context. Take the node, which is relevant for the change in each row (I assume it is TRIPS) and bind the table to the node as you are used to. Then for each additional column, you have to create a new column in the tree, create a new header element with a title and a new editor (e.g. textview or inputfield) and then bind the right property of the editor to the corresponding attribute in node AMOUNTS).
    If these 2 nodes do not have parent-child-relationship, the tip to create a new node, which consists of the attributes of both nodes is the only solution.
    Ciao, Regina

  • How to find the Values of SAP Gateway Server Host  and Gateway Service Valu

    Hi All,
    I installed SAPR/3 4.7 EE on Windows. For configuring SLD and LDAP i am unable to give the SAP Gateway Server Host and Gateway Service values.
    Can any one plz suggest me how to find these values.
    Regds
    Phanikumar

    Hello, SAP Gateway Server Host and Gateway Service are used to set up rfc connectivity, that is the host name and the system number where your sld and ldap is responding, if you have no sld and no ldap , just simply uncheck that options while installing.
    Have a nice week end, Luciano.

  • Psd file format specification how get the pixel values

    Hello
    I'm trying to convert psd to xml and get all information from layers
    I already got all necessary  info  but for example  the radius  in rounded rectangle is in math double format but I need to have it in pixels.
    I'm using Adope photoshop file format specification but  there is no information how to convert double values to pixels,
    The same is with colors that also given in double.
    I need to know how to convert these values to actual values
    Thanks

    Hi,
    You can't do that. You have to format the numbers before you print them. Take a look at the decimal format class:
    http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html
    /Kaj

Maybe you are looking for

  • How do I reinstall my Airport extreme?

    I am having problems reinstalling my airport extreme, I need to reconfigure it, having security issues.Please helping me , do I need to un install first, to reconfigure set up.

  • Acrobat 9 Pro Scan Problem

    Using Adobe Acrobat 9 Pro version 9.5.1 - All of a sudden scanned documents are showing all dark grey. It was working perfect 2 days ago. All documents are scanned through the Epson scanner.  I searched updates, checked plug-ins and even did a 'repai

  • Foreign trade / Customs info

    Hello experts, I have a problem with billing split. The scenario is the following: I have created a purchasing organization that belongs to a society called UMA. This purchasing organization has a plant (UMC) without any warehouse (at the moment, it

  • I click "Visit your website" and get a SORRY page

    When at my website pages on my desktop (the working pages), I click onto VISIT (your website) and I get that SORRY we couldn't find it page. The URL that shows in the address field is: http://web.mac.com/lorna6/Websiteof_LornaAlexander/Welcome.html I

  • Photoshop File Compatibility

    Why doesn't lightroom recognize Photoshop files that are not saved with maximum compatibility checked on the save dialog? Almost all of my psd's have been saved w/o max comp. and now I can't view them in Lightroom. In addition to the pain of having t