How to group the values according to the weeks of the year?

Hello

I have a table with dates and values (I'm simplifying the need for this question)

I want to group the values (and adding the) according to the 52 weeks of the year. I mean week of consolidation for the week.
Here the date of each weeks generated during a year, it gives every Monday of each week of the year:
Select trunc (trunc (sysdate, 'year'), 'iw') +(rownum*7)-7 n of object where rownum < = 53

What I want to do is to summarize the values in my table and group together them in every week, in that respect. The date of these weeks are generated by the above query.

For example all values fall into the 1st week of the year will be grouped into this date, all values fall in the 2nd wek will be grouped in this date and so on. If no value is found for a week, then a value of 0 is generated in iorder have a 52 weeks-lines. It's basically a kind of select with "date between... and...". "and group values and that affect the number of the wee, they are relevant.

Examples of Monday, June 30, 2008, 07/07/2008, 07/14/2008

Example of values and dates in my table:

Date value
30/06/08 9
07/01/08 9
07/02/08 9
07/03/08 9
07/03/08 9
07/04/08 6
07/04/08 6
07/04/08 9
07/07/08 9
07/08/08 9
29/07/08 9
29/07/08 6
30/07/08 9
07/31/08 9
07/31/08 9
07/31/08 9
08/01/08 9
08/04/08 5.5
08/04/08 9
08/07/08 9
08/07/08 9
08/08/08 9
14/08/08 9
14/08/08 9
18/08/08 9
22/08/08 9
22/08/08 9
25/08/08 9
25/08/08 9
26/08/08 9
29/08/08 9
29/08/08 9
09/01/08 9
09/01/08 9
09/04/08 9
09/04/08 9
09/05/08 9
09/05/08 9
09/05/08 9
09/05/08 9
17/09/08 9

Result should be something like this:

Number of the week Date value
47/1 12/31/2008
94/2 07/12/2008
2008-01-14 3, 23
and so on...
.....
73/52 12/22/2008
60/53 29/12/2008

I hope I am clear. Thank you for your kind replies.

Something like that, maybe:

select trunc(trunc(sysdate,'year'),'iw') +((level-1)*7)  n
from dual connect by level<=53

(I changed it to sysdate so that the next years will take care of them!)

Tags: Database

Similar Questions

  • It costs more to go to monthly payments?  How to pass the year to monthly payments?

    It costs more to go to monthly payments?  How to pass the year to monthly payments?

    Diane H,

    Yes, the month subscriptions are expensive as they come without see all annual contract, Adobe - General conditions of subscription

    To change your plan see, update or change your plan creative cloud

    Let us know if that helps.

    Kind regards

    Bani

  • How to group the returned records

    My current Recordset returns the following:

    Africa

    Egypt

    Africa

    Namibia

    Africa

    Morocco

    Central America

    Mexico

    The North America

    United States

    The North America

    Canada

    How to group set of records according to the regions? It returns the following (taken from a book exercise):

    Africa

    Egypt

    Namibia

    Morocco

    Central America

    Mexico

    The North America

    United States

    Canada

    MySQL select statement:

    @mysql_select_db ($database_conn_newland, $conn_newland);
    $query_rs_countriesbyregion = 'SELECT countryID, region, countryName, regionID, regionName FROM tbl_country, tbl_region WHERE tbl_country.region = tbl_region.regionID ORDER BY regionName ASC';
    $rs_countriesbyregion = mysql_query ($query_rs_countriesbyregion, $conn_newland) or die (mysql_error ());
    $row_rs_countriesbyregion = mysql_fetch_assoc ($rs_countriesbyregion);
    $totalRows_rs_countriesbyregion = mysql_num_rows ($rs_countriesbyregion); @mysql_select_db ($database_conn_newland, $conn_newland);

    My table code:

    < body >
    the strong group > < h2 > < by region: facilities > < / h2 >
    < table width = "30%" border = "0" cellspacing = "0" cellpadding = "3" >
    <? PHP {? >}
    < b >
    < scope = "col" td > < strong > <? PHP echo $row_rs_countriesbyregion ['regionName'];? > < / strong > < table >
    < /tr >
    < b >
    < td > <? PHP echo $row_rs_countriesbyregion ["countryName"];? > < table >
    < /tr >
    <? PHP} while ($row_rs_countriesbyregion = mysql_fetch_assoc ($rs_countriesbyregion));? >
    < /table >

    Please help or direct me to a web resource.

    I would do something like this:


     
              
             


               
             
               


         
       
       
       

    Moreover, Mexicans don't consider themselves not part of Central America!

    Ed

  • How to group these values by month?

    Hello

    I have a nice SQL statement that returns from day to day, 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 n
    Sample 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 grouped values from day to day. I would like to tehse group monthly values, but couldn't figure out how to do. Even if I'm not a newbie to newbie on SQL, copy the following code will much too much for me. I know that some of you guys can handle that. I tried but not sew succeed. Could you help me?

    Best regards, Christian.
    select add_months(to_date('01/01/2006', 'dd/mm/yyyy'), level - 1) n,
           rownum
    from   dual
    connect by level <= 12;
    
    N             ROWNUM
    --------- ----------
    01-JAN-06          1
    01-FEB-06          2
    01-MAR-06          3
    01-APR-06          4
    01-MAY-06          5
    01-JUN-06          6
    01-JUL-06          7
    01-AUG-06          8
    01-SEP-06          9
    01-OCT-06         10
    01-NOV-06         11
    01-DEC-06         12
    
  • How to calculate the year last month in obiee 11g?

    Hello

    I want to calculate the year last month in obiee 11g. I tried DB.

    -SELECT TO_CHAR (ADD_MONTHS (SYSDATE,-12), 'YYYYMMDD') FROM DUAL;

    Using the above query, year last month is -"08-01-2015"

    But I want to get the same result using timestampadd() in obiee 11g.

    Please help me,

    Thanks in advance,

    A.Kavya

    Hello

    TIMESTAMPADD (SQL_TSI_YEAR-1, CURRENT_DATE)

  • How to display a value according to the position of the arrow of the mouse?

    Hello world

    I change the color of the background of some indicators according to temperature measurements. Each context is bound to a temperature. I want to show the value of the temperature during the passage of my mouse on the indicator arrow. I don't want the before diagram with all temperatures cooler.

    Is this possible? The temperature might appear in a single, fixed, indicator or related to the arrow...

    Any help would be great,

    Thank you

    User

    Is this what you need?

  • How to group the "others."

    Hello

    I need to combine my settings to the 'others' when I've used the values I need, without the scabbard, if possible.

    Example to be more clear:

    I have the settings: A, AB, ABC, ABCD, ABCDE, ABCDEF, ABCDEFG.

    I need to show: A, ABC, ABCDEFG and the rest as "Other", how can I do this? In the table is the best way? Be a better way in OBI?

    Thanks in advance.

    MrTiberio wrote:
    Hello

    I need to combine my settings to the 'others' when I've used the values I need, without the scabbard, if possible.

    Example to be more clear:

    I have the settings: A, AB, ABC, ABCD, ABCDE, ABCDEF, ABCDEFG.

    I need to show: A, ABC, ABCDEFG and the rest as "Other", how can I do this? In the table is the best way? Be a better way in OBI?

    Thanks in advance.

    Mr. Tiberio, it looks like my answer for you in the other question you have asked. (Btw, when you want to sort in a PivotTable, for example in the lines section, it should be the first column, so if you want the real column in another post, simply create a layer duplicated this column, move it all the way to the left, the sort and hide the column.)

    (1) create the BINS. Take another instance of the column in question.

    2) click the button fx to the column. At the top is another default tab: BINS. Until it clicks.

    2) click on the 'Add BINS' button on the bottom and add a LOCATION for each of the specific type of the parameter. Add the A, ABC, ABCDEFG in the filter to edit/create window, click 'OK' and give him a proper label.

    (3) for the rest, make sure the label 'others '.

    You can now use this column of BOXES in the PivotTable Section or in the Pages section so that users can choose. Put the column in the row and the column of TANKS section in the section Pages or Sections. That is my suggestion.

    Edited by: David_T April 26, 2012 07:53

  • How to group the text on the Razr Maxx-JB 4.1.1 HD

    I have a problem, try to send a group text.

    Icon text not available when looking at groups of people.

    Groups are not available in searching of text messaging contacts.

    Any ideas?

    Thanks in advance, Dave

    Unfortunantly Jelly Bean removed the group send TEXT messages and emails. It has also affected other Jelly Bean phones more only Motorola products. I suggest you use a text messaging application, most SMS apps allow to send group SMS.

    http://androidforums.com/Samsung-Galaxy-S3/651408-group-texting-problem-t-mobile-GS3.html

    http://forums.androidcentral.com/t-Galaxy-s-III/187638-group-texting-help.html

  • How to get the year and month of a whole year

    Hello

    I have a list of selection and when the user selects the list values are like this 201101,201102,201103

    I tried like this


    declare
    T_DATE varchar2 (25);
    Start
    because me in 1.12 loop
    Select TO_CHAR (ADD_MONTHS (SYSDATE, + 1), "YYYYMM") in the double T_DATE;
    dbms_output.put_line (V_DATE);
    end loop;
    end;

    But its bad and I can not get clear idea where to change the code

    Thanks and greetings
    Srikkanth.M

    Srikkanth.M wrote:
    Hello

    I have a list of selection and when the user selects the list values are like this 201101,201102,201103

    If you want to list for the current year from Jan 201101,201102, 201103... 201112, then try this

    DECLARE
      v_Date  VARCHAR2(25);
      n_month NUMBER;
    BEGIN
      SELECT extract (MONTH FROM sysdate) INTO n_month FROM dual;
      FOR i IN 1..12
      LOOP
        SELECT TO_CHAR(ADD_MONTHS(SYSDATE, (i-n_month)), 'YYYYMM')
        INTO v_date
        FROM dual;
        dbms_output.put_line(v_date);
      END LOOP;
    END;
    

    Vivek L

  • How to get the year of Date data

    Hi all

    I have the following scenario:

    County - Date - Code
    5 DS - 01/09/2009
    5 DS - 15/01/2009
    5 LO - 21/01/2009
    1. IT - 02/09/2009
    5 DS - 03/09/2009
    5 LO - 04/09/2009
    4 DS - 05/09/2009
    5 - IS - 06/09/2009
    5 DS - 07/09/2009
    5 - IS - 08/09/2009
    3 DS - 09/09/2009
    5 DS - 10/09/2009
    5 LO - 11/09/2009
    2 DS - 12/09/2009
    5 DS - 01/09/2010
    5 LO - 02/09/2010
    4 DS - 03/09/2010

    How can I only CDA data for 2009 and one year for 2010... Is meant by CDA 2009 data until the day of the date for example, if its 9 March today... TBE outcome will bring full jan, Feb and until the 9th day of March ' 09 and full jan, Feb and until the 9th day of March 10

    Thank you

    Published by: [email protected] on March 9, 2010 23:03

    Published by: [email protected] on March 9, 2010 23:06

    Something like:

    where dt <= trunc(dt,'YYYY')+(trunc(sysdate,'DD')-(trunc(sysdate,'YYYY'))
    

    "Dt" corresponding to your date column.

  • PrePay CC subscription.    Can someone tell me how to pay the year reduced through Adobe in advance?

    Hi, I normally pre pay my bills subscription and so far, every public utility company has provided a method to do this... so far, as far as I can tell.      Adobe, is there a way to pay before the subscription?   If not, is there a prepaid card /good/ solve one I can buy * and forget * you can recommend? I'll happily pay a rate increased slightly to ensure that everything is paid and I don't have to think about.  As far as I know, each of them have transaction fees or monthly subscription fees that are 'forget' dangerous for your credit.

    Thoughts?

    Suggestions?

    Hello

    When you associate a credit card to your account when you purchase a subscription (annual) of CC, the same is auto-facturé each month or that you don't need to explicitly make a payment. Only your credit card must be in good and due form - i.e. active card with sufficient funds etc..

    However, your concern is valid and duly noted.

    In addition, please see the section "can I pay for my membership creative cloud" FAQ at http://www.adobe.com/products/creativecloud/faq.html#purchasing-availability.

    Thank you

    CharAt()

  • How to upgrade the ArrayCollection collection when running?

    Am facing a problem with the arraycollection collection...
    will have an arraycolelction like that...
    var dpHierarchy:ArrayCollection = new ArrayCollection([)
    {Region: "Application1"},
    {Region: "Demand2"},
    {Region: "Demand3"},
    [{Region: "APPROVISIONNEMENTS4"}]

    now what I'm looking for is... How to upgrade this arraycollection collection during execution using actions script?
    I need to update this collection table something like this...

    var dpHierarchy:ArrayCollection = new ArrayCollection([)
    {Region: "Application1", year: '2008'},
    {Region: "demand2', year: '2008'},
    {Region: "Demand3', year: '2008'},
    [{Region: "APPROVISIONNEMENTS4", year: '2008'}]

    How to add the year field in to existing collection arraycollection as shown in the example...

    Thanks in advance
    Pratap

    Hey get...

    I have to just give

    dpHierarchy [0] ['year'] = '2008 '.

    :-)

  • problem of formatting of the year

    Hey people,

    I'm trying to create a simple list of values to display the dates of 6 years in the current year. Nothing fancy, just two fields, which are supposed to return data as well:

    02 - 2002
    03 - 2003
    04 - 2004
    05 - 2005
    06 - 2006
    07 - 2007
    08 - 2008

    The SQL I use is this:

    SELECT
    To_char(sysdate,'YY') + ROWNUM-return, 7
    View from to_char(sysdate,'YYYY') + ROWNUM-7
    (
    SELECT 1
    OF the double
    connect by level < = 7
    );

    There might be an easier way to do it, but it's as simple as I could do.

    Now my problem is, the data is not returned properly, instead it gives me:

    2 - 2002
    3 - 2003
    4 - 2004
    5 - 2005
    6 - 2006
    7 - 2007
    8 - 2008

    and I really need those zeros not significant (I build drop-down lists for a payment form). I tried various permutations of TO_CHAR, TO_NUMBER, TO_DATE, but so far I have not been able to find how to get the year should see '08' and not just '8 '.

    So if anyone has an idea of what I'm doing wrong, I would be very grateful for any help that you could give. I apologize if this is too simple for words...

    See you soon

    Hi check this query

    SELECT
    lpad(TO_CHAR(sysdate,'YY')+ROWNUM -7,2,'0') return,
    TO_CHAR(sysdate,'YYYY')+ROWNUM -7 display
    FROM DUAL
    connect by level <=7
    
  • How to group and summarize the values with a vertical drop of 100?

    Dear gurus
    How to group and summarize the values with a vertical drop of 100 as the data indicated below:

    Cas_Cod_ Cas_Amt_ Description
    300 1000A
    301 200 B
    302 350 C
    400 500 A
    401 100 B
    402 25

    Now the data should be grouped like this
    A (300,400) = 1500
    (301,401) B = 300
    C (302,402) = 375

    Make sure that I don't have a column as description in my table to group data on description, its here just to give u an example.

    Hello

    using mod for hundreds:

    with x as
    (
      select 300 code, 1000 amt, 'A' descr from dual union all
      select 301 code, 200 amt, 'B' descr from dual union all
      select 302 code, 350 amt, 'C' descr from dual union all
      select 400 code, 500 amt, 'A' descr from dual union all
      select 401 code, 100 amt, 'B' descr from dual union all
      select 402 code, 25 amt, 'C' descr from dual
      )
       select mod(code,100) code, sum (amt)
        from x
       group by mod(code,100);
    

    Using the mod you get the rest of a division, so mod (300,100) = 0, mod (301,100) = 1, etc.

    Herald tiomela
    http://htendam.WordPress.com

  • How to set the initial value for a single radiobutton in a group of Radio buttons

    Hi all

    I have a radiogroup with 3 buttons. The names of the RadioGroup are driven out of a XXVO.

    3 Radion buttons:

    + 9
    * XX
    * XXX

    When loading the Page I want to make an XXX option button to be the default, please suggest how.

    Note: The radiobutton values come from VO

    Thank you

    Hello

    XXCONTACT_ADDR_BUTTON1 - is the value of the radio button to select the right...

    Very well.. :))

    Concerning
    Meher Irk

Maybe you are looking for