sum of the months of data first weeks

1 January 09 5
January 2 09 3
January 3 09 2
:
:
:
1 February 09 1
February 2 09 1
February 3 09 1
4 February 09 1
5 February 09 1
6 February 09 1
February 7 09 1

For any date in January I should get the sum of the values of the next month first week i, e 1 February to 7 February 09 09
for example, 01 - jan - 09 = 7
:
:
29 jan - 09 = 7
It will be better if you give the query I have terms of

Sum (a) over (partition by order b by c lie between the interval Trunc (Trunc (sysdate, 'MONTH') + 1, 'MONTH') day following and '7' next day)

Hello

When you use a DATE column, specify the RANGE as a number of days:

SELECT  SUM (a) OVER ( PARTITION BY     b
                               ORDER BY          c
                 RANGE BETWEEN     ADD_MONTHS (TRUNC (c, 'MM'), 1)           - c  FOLLOWING
                          AND     ADD_MONTHS (TRUNC (c, 'MM'), 1) + 6.99999 - c  FOLLOWING  -- Not 7, as origninally posted
               )  AS next_month_week_1_a

Published by: Frank Kulash, March 11, 2009 12:41

Fixed bug reported by Blushadow.

Tags: Database

Similar Questions

  • How to find the sum of the month and year of a date

    Hi all

    I want to find the sum of the date
    for example, 10 November 2010 I need to find (11-2010).

    Please help me

    You can use the extract function...

    SQL> select extract(month from systimestamp)+extract(year from systimestamp) from dual;
                EXTRACT(MONTHFROMSYSTIMESTAMP)+EXTRACT(YEARFROMSYSTIMESTAMP)
                                        ------------------------------------------------------------
                                                            2021
    

    Concerning
    Renjith Malet

  • Select records based on the monthly anniversary date

    Hello

    I have a table with a field of date_added and I want to select records from monthly birthday of this field.

    for example. ID, Date_added
    1, DECEMBER 10, 2012
    2, 11 NOVEMBER 2012
    3, 10 MARCH 2012
    4, FEBRUARY 28, 2012
    5, 30 DECEMBER 2012

    So for January 10, 2013, I would like to return the documents 1 and 3 only

    I started watching the extract function, but this little falls down to the records at the end of the month. For example, on 28 February, I also include records where 29, 30 or 31 is the day of date_added. So, in the above table, I won't return documents 4 and 5, but retrieves only returns 4.

    Is there a simple function to make the request of birthday this month - have I missed something very obvious? Or I have to write a query to explicitly dates at the end of the month? So far I have not found a reasonable solution!

    I use 11g

    Thank you

    user11259857 wrote:
    Hi Al,.

    No I don't think that there is a flaw. For example, the 30 Jan is not the last day of the month, but is June 30. Thus, on 30 January I want only to interrogate all the dates falling on the 30th - 28 February, after already being interrogated on the 28 Jan. However, on 30 June, I would query the 30th of each month, as well as the 31 January, March, may, July, Aug, Oct, dec. February is a special case, being both shorter and a leap year

    Thank you

    Richard

    Hi Richard,

    so, we can assume that your needs are:

    If the day is the last day of that month, interview the day of the other months being > = day of the current month.

    That is to say:

    Jan-30 = query only 30 other months
    Jan-31 = query only 31 of the other months

    Feb-28 (non-leap years) = question 28, 29, 30 and 31 other months
    29 February (leap year) = query 29,30,31 to other months

    Mar-30 = query only 30 other months
    Apr-30 = query 30 and 31 other months

    This hypothesis is correct?

    If so, then something like this should work:

    WITH mydates(id, date_added) AS
    (
       SELECT 1, TO_DATE('10-DEC-2012', 'DD-MON-YYYY') FROM DUAL UNION ALL
       SELECT 2, TO_DATE('11-NOV-2012', 'DD-MON-YYYY') FROM DUAL UNION ALL
       SELECT 3, TO_DATE('10-MAR-2012', 'DD-MON-YYYY') FROM DUAL UNION ALL
       SELECT 4, TO_DATE('28-FEB-2012', 'DD-MON-YYYY') FROM DUAL UNION ALL
       SELECT 5, TO_DATE('30-DEC-2012', 'DD-MON-YYYY') FROM DUAL
    )
    SELECT id, date_added
      FROM mydates
     WHERE (:input_date = LAST_DAY(:input_date) AND TO_CHAR(:input_date,'DD') <= TO_CHAR(date_added, 'DD'))
        OR TO_CHAR(:input_date,'DD') = TO_CHAR(date_added, 'DD');
    
    with input_date = 28/02/2013
    
    id   date_added
    4    28/02/2012
    5    30/12/2012
    

    Kind regards.
    Al

    Published by: Alberto Faenza on 10 January 2013 15:21
    Added example

  • Dynamic calc to calculate the sum of the months in the years

    I have a 6.5.5 Essbase cube with a size of periods containing months and weeks as members stored, labeled as time. I also have a dimension of the year that contains exercises and these members can also be stored. I have to add together the first month of this year and the last month of last year.

    I can do this:

    M12-LY + M01-> TY >

    Gives me the right answer and I could configure IF statements through Sunday to the correct value of LY, but I would like the formula dynamically select the correct LY based on the year TY that the user puts in place in their query. I tried some combos using @prior and @shift and it is not working properly.

    Here is what I thought might work:

    M01 + (@SHIFT (Year-1));

    This formula results by adding just the M01 and nothing of LY. Any thoughts on how to configure this formula?

    Published by: user11908498 on 16 Sep, 2009 05:55

    Published by: user11908498 on September 16, 2009 11:42

    What your year Sun look like?

    The support is that it looks like this

    Year
    -2008 (LY)
    -2009 (TY)

    So if you're on TY, then shift - 1 (or before) it would go to the 2008 (LY)

    By chance your year sun goes in the opposite direction

    Year
    -2009 (TY)
    -2008 (LY)

    In this case, you will have to go the other way

    "M01" + @SHIFT ("M12", 1, @CHILDREN ("Year"));

  • calculate the month to date in Obiee11g

    Hello
    I use OBIEE11g, im a problem-

    Problem: results of the beginning of this month beginning of previous month results vs.
    example: If Im in 12 February the calculation is * February 1 to February 12 * also * January 1 to January 12 *.

    -Zia

    Can you give your month there is calculation please?

    It is similar to the AGO (SH. Salesfacts. "" Quantity ", SH. TimesDim. ("" Month ", 1).

  • Breaking a year in coming weeks of beginning and end Dates (parameters) and first and last day of the month

    Hello people:

    I have currently a query that picks up all the weeks between a date range where my week starts on Thursday and ends on Wednesday. The following query works fine except that I need the week of beginning and end, from beginning and end Dates of months and the beginning and the Dates of end of the values of the settings, I'm passing. In this case, I chose January 1, 2013 to 31 December 2013.

    Any help or pointers would be great!

    Thank you!

    Problem: I am picking up days of December 2012 as the first week began on December 27, 2012. In addition, in December, I'm pretty much lost last week as well (26 December - 31 December).

    The request in hand:

    SELECT first_thursday + (7 * (LEVEL - 1))   AS week_start_date,
                     first_thursday + (7 * LEVEL) - 1    AS  week_end_date
    FROM
    (
      SELECT TRUNC(p_from_date + 4, 'IW') - 4   AS first_thursday, -- Week should start the pre ceeding THURSDAY based on the Start Date
                      TRUNC( p_to_date + 4,  'IW') - 5     AS last_wednesday
      FROM
      (
        SELECT to_date('01-JAN-2013') AS p_from_date,
                        NVL(to_date('31-DEC-2013'), SYSDATE) AS p_to_date
        FROM     dual
      ) parms
    ) end_points
    CONNECT BY LEVEL <= ( last_wednesday + 1 - first_thursday)/7;
    

    Currently, this is the result I get (I'm only including the months of January and December here).

    Week_Start_Date     Week_End_Date
    27-DEC-12                02-JAN-13
    03-JAN-13                 09-JAN-13
    10-JAN-13                 16-JAN-13
    17-JAN-13                 23-JAN-13
    24-JAN-13                 30-JAN-13
    31-JAN-13                 06-FEB-13
    

    December:

    28-NOV-13               04-DEC-13
    05-DEC-13              11-DEC-13
    12-DEC-13              18-DEC-13
    19-DEC-13              25-DEC-13
    

    What I would really like is based on start and end Dates, as well as the first and the last day of the month is similarly try nicely. I have provided and then gently break at the end of the month:

    January:

    01-JAN-13              02-JAN-13
    03-JAN-13              09-JAN-13
    10-JAN-13             16-JAN-13
    17-JAN-13             23-JAN-13
    24-JAN-13             30-JAN-13
    31-JAN-13             31-JAN-13
    

    February:

    01-FEB-13    06-FEB-13
    07-FEB-13    13-FEB-13
    14-FEB-13    20-FEB-13
    21-FEB-13    27-FEB-13
    28-FEB-13    28-FEB-13
    

    November:

    31-OCT-13    06-NOV-13
    07-NOV-13    13-NOV-13
    14-NOV-13    20-NOV-13
    21-NOV-13    27-NOV-13
    28-NOV-13    04-DEC-13
    

    December:

    01-DEC-13           04-DEC-13
    05-DEC-13           11-DEC-13
    12-DEC-13          18-DEC-13
    19-DEC-13          25-DEC-13
    26-DEC-13          31-DEC-13
    

    Hello

    Roxyrollers wrote:

    Hello people:

    I have currently a query that picks up all the weeks between a date range where my week starts on Thursday and ends on Wednesday. The following query works fine except that I need the week of beginning and end, from beginning and end Dates of months and the beginning and the Dates of end of the values of the settings, I'm passing. In this case, I chose January 1, 2013 to 31 December 2013.

    Any help or pointers would be great!

    Thank you!

    Problem: I am picking up days of December 2012 as the first week began on December 27, 2012. In addition, in December, I'm pretty much lost last week as well (26 December - 31 December).

    The request in hand:

    1. First_thursday SELECT + (7 * (LEVEL - 1)) AS week_start_date,
    2. first_thursday + (7 * LEVEL)-1 AS week_end_date
    3. Of
    4. (
    5. SELECT TRUNC (p_from_date + 4, 'IW') - 4 AS first_thursday,-week should start to perform the pre-mounted THURSDAY based on the Start Date
    6. TRUNC (p_to_date + 4, 'IW') - 5 AS last_wednesday
    7. Of
    8. (
    9. SELECT to_date('01-JAN-2013') AS p_from_date,
    10. NVL (to_date('31-Dec-2013'), SYSDATE) AS p_to_date
    11. OF the double
    12. ) parms
    13. ) end_points
    14. CONNECT BY LEVEL<= (="" last_wednesday="" +="" 1="" -="">

    Currently, this is the result I get (I'm only including the months of January and December here).

    1. Week_Start_Date Week_End_Date
    2. DECEMBER 27, 12 2 JANUARY 13
    3. JANUARY 3, 13 JANUARY 9, 13
    4. 10 JANUARY 13 JANUARY 16, 13
    5. 17 JANUARY 13 23 JANUARY 13
    6. 24 JANUARY 13 30 JANUARY 13
    7. 31 JANUARY 13 FEBRUARY 6, 13

    December:

    1. NOVEMBER 28, 13 4 DECEMBER 13
    2. 5 DECEMBER 13 DECEMBER 11, 13
    3. 12 DECEMBER 13 18 DECEMBER 13
    4. 19 DECEMBER 13 DECEMBER 25, 13

    What I would really like is based on start and end Dates, as well as the first and the last day of the month is similarly try nicely. I have provided and then gently break at the end of the month:

    January:

    1. JANUARY 1, 13 2 JANUARY 13
    2. JANUARY 3, 13 JANUARY 9, 13
    3. 10 JANUARY 13 JANUARY 16, 13
    4. 17 JANUARY 13 23 JANUARY 13
    5. 24 JANUARY 13 30 JANUARY 13
    6. 31 JANUARY 13 JANUARY 31, 13

    February:

    1. 1ST FEBRUARY 13 FEBRUARY 6, 13
    2. 7 FEBRUARY 13 FEBRUARY 13, 13
    3. 14 FEBRUARY 13 FEBRUARY 20, 13
    4. 21 FEBRUARY 13 FEBRUARY 27, 13
    5. 28 FEBRUARY 13 FEBRUARY 28, 13

    November:

    1. 31 OCTOBER 13 NOVEMBER 6, 13
    2. 7 NOVEMBER 13 NOVEMBER 13, 13
    3. 14 NOVEMBER 13 NOVEMBER 20, 13
    4. 21 NOVEMBER 13 NOVEMBER 27, 13
    5. NOVEMBER 28, 13 4 DECEMBER 13

    December:

    1. 1ST DECEMBER 13 DECEMBER 4, 13
    2. 5 DECEMBER 13 DECEMBER 11, 13
    3. 12 DECEMBER 13 18 DECEMBER 13
    4. 19 DECEMBER 13 DECEMBER 25, 13
    5. 26 DECEMBER 13 DECEMBER 31, 13

    Why the "weeks" in November, have all 7 days, while the "weeks" in the first or the last week in the other month usually have less?  (For example, February 28 is a 'week' alone.)

    The following works for the other months:

    WITH all_days AS

    (

    SELECT DATE "2013-01-01' + LEVEL - AS a_date 1

    OF the double

    CONNECT BY LEVEL<=>

    )

    SELECT DISTINCT

    More GRAND (TRUNC (a_date + 4, 'IW') - 4)

    , TRUNC (a_date, 'MONTH')

    ) AS week_begin

    , The LEAST (TRUNC (a_date + 4, 'IW') + 2

    TRUNC (LAST_DAY (a_date))

    ), Week_end

    Of all_days

    ORDER BY week_begin

    ;

    Output:

    WEEK_BEGIN WEEK_END

    ----------- -----------

    January 1, 2013 January 2, 2013

    January 3, 2013 January 9, 2013

    January 10, 2013 January 16, 2013

    January 17, 2013 January 23, 2013

    January 24, 2013 January 30, 2013

    January 31, 2013 January 31, 2013

    February 1, 2013 February 6, 2013

    February 7, 2013 February 13, 2013

    February 14, 2013 February 20, 2013

    February 21, 2013 February 27, 2013

    February 28, 2013 February 28, 2013

    ...

    November 1, 2013 November 6, 2013

    November 7, 2013 November 13, 2013

    November 14, 2013 November 20, 2013

    November 21, 2013 November 27, 2013

    November 28, 2013 November 30, 2013

    December 1, 2013 December 4, 2013

    December 5, 2013 December 11, 2013

    December 12, 2013 December 18, 2013

    December 19, 2013 December 25, 2013

    26 December 2013 31 December 2013

  • calculation of the week and the month of the column date

    I have 3 data as column
    with tab as 
    (
      select 'Topshop' brand, '10-JUL-11' deliverydate, '100' qty from dual union all
      select 'Topshop' brand, '10-JUL-11' deliverydate, '400' qty from dual union all
      select 'NewSita' brand, '11-JUL-11' deliverydate, '200' qty from dual union all
      select 'LaGress' brand, '12-JUL-11' deliverydate, '300' qty from dual union all
      select 'LaGress' brand, '10-AUG-11' deliverydate, '100' qty from dual union all
      select 'LaGress' brand, '11-AUG-11' deliverydate, '200' qty from dual union all
      select 'Topshop' brand, '12-AUG-11' deliverydate, '300' qty from dual union all
      select 'NewSita' brand, '10-SEP-11' deliverydate, '100' qty from dual union all
      select 'Topshop' brand, '11-SEP-11' deliverydate, '200' qty from dual union all
      select 'NewSita' brand, '12-SEP-11' deliverydate, '300' qty from dual
    ) select * from tab
    I need to convert it to 4 columns

    Brand | Month | Week (start date). Amount (sum)

    Please let me know what are the options I have, in particular the calculation of date and time functions available to solve these problems.

    Thank you
    w\

    Check this box

    with tab as
    (
    Select the option 'Topshop' brand, July 10, 11 'deliverydate, ' 100' qty of any union double
    Select the option 'Topshop' brand, July 10, 11 'deliverydate, ' 400' qty of any union double
    Select the option "NewSita" brand, 11 July 11 'deliverydate, ' 200' qty of any union double
    Select "brand the LaGress, 12 July 11' deliverydate, '300' qty of union double all the»
    Select "brand the LaGress, 10 Aug 11' deliverydate, '100' qty of union double all the»
    Select "brand the LaGress, 11 Aug 11' deliverydate, '200' qty of union double all the»
    Select the option 'Topshop' brand, 12 Aug 11 'deliverydate, ' 300' qty of any union double
    Select the brand 'NewSita',' 10-SEP-11 deliverydate, '100' qty of all double union
    Select the option 'Topshop' brand,' 11-SEP-11 deliverydate, '200' qty of any union double
    Select the option "NewSita" brand, deliverydate, '300' qty of the double' 12-SEPT-11
    ) select the brand, deliverydate, NEXT_DAY (to_date (deliverydate, 'DD-MON-yy'), "LUN")-7, Qty tab.

  • calculate a date field first of the month

    I need to calculate a date field using date of hire as a base date, and it should return the first of the month following 30 days of date of hire.  (date of rental + 30 days then first of the month following that date).

    Hello margery497,

    In this scenario, you can create a text field 1 with validation as a calculated field and can add now() formula inside. Then, in the text field 2, you can add the now() + 30 formula and save it with the calculated field.

    Here is the reference for validating field:

    http://helpx.Adobe.com/EchoSign/KB/form-fields---validations.html

    Kind regards

    -Usman

  • Select the first 20 days of the month for a given date

    Hi gurus,

    Please let me know to select the first 20 dates for a date supplied by using a parameter.

    For ex -.

    Suppose I provided a date by using a parameter - January 13, 2012

    The query should return me - 01-Jan-2012, January 2, 2012... January 20, 2012

    or if I get home on 23 March 2012

    The query should return me - 01-Mar-2012, March 2, 2012... 20 March 2012

    Thanks in advance.

    Hello

    Here's one way:

    VARIABLE  target_date     VARCHAR2 (11)
    EXEC     :target_date := '13-Jan-2012';
    
    SELECT      TO_DATE ( SUBSTR (:target_date, 4)
                , 'Mon-YYYY'
               ) + LEVEL - 1     AS a_date
    FROM     dual
    CONNECT BY     LEVEL     <= 20
    ;
    

    Note that this does not take account the part of: target_date that represents the day of the month. When you use TO_DATE without giving a date of the month, it defaults to the 1st of the month.

  • get the first week of the month

    Hello
    How to get the first week of the month of request

    I tried this, but not gwtting

    SELECT THE DOUBLE TO_CHAR('09/30/2007','W')

    Thank you

    Published by: 896398 on January 18, 2012 03:17
    SQL> select to_char(to_date('07-12-2008', 'DD-MM-YYYY'), 'W') from dual; 
    
    T
    -
    1
    
    SQL> select to_char(to_date('14-12-2008', 'DD-MM-YYYY'), 'W') from dual; 
    
    T
    -
    2
    
    SQL> select to_char(to_date('23-12-2008', 'DD-MM-YYYY'), 'W') from dual;
    
    T
    -
    4
    

    HTH

    Kind regards
    NORTH CAROLINA

  • start date for each week of the month

    Dear members

    How can I find double, the start date of each week of the month in a year.
    beginning of the week is the word "Monday".


    year month week day date
    ----------------------------------------------------------------------------------------
    Monday, January 3, 2011 JAN 1, 2011
    2011 2 JAN Monday, January 10, 2011
    Monday, January 17, 2011 January 3, 2011
    JAN 4 2011 on Monday, January 24, 2011
    2011 to January 5 Monday, January 31, 2011


    Thank you

    teefu

    Hello

    You can use this:

    with t as  (select to_date ('01/01/2011', 'DD/MM/YYYY') start_date from dual)
    select  date_calc
    from (
            select  start_date,
                    (level-1)*7+trunc (start_date , 'D')+1   as date_calc
            from t
            connect by level <=53)
    where trunc(date_calc,'YYYY')=trunc(start_date,'YYYY') ;
    

    Kind regards
    Sylvie

  • How to get the Date in month based on week of the month.

    Hi gurus,

    I have provided.

    Quarter (Q) = > 1 (Jan - Mar), 2 (April-June), 3 (July-September), 4 (October-December).

    Months (M) = > Jan = 1, Feb = 2, Mar = 3 in the 1st quarter.

    ARP = 1, may = 2, Jun = 3 in the 2nd quarter,

    Jul = 1, August = 2, Ms = 3 in Q3,

    Oct 1 Nov = = 2, Dec = 3 in the 4th quarter

    If I give Q = 3, M = 3, W = 1 day = Fri so I get 6-Sep-13

    Similarly, if I give Q = 2, M = 1, O = 3, day = game so I get 18 April 13.

    Could someone help me higher and higher.

    Concerning

    Sanjeev

    Believing that when you say you want to say that it is 1 - 5 in a month with the 1st day of the month as the beginning of the 1st week of the week. You can try this.

    SQL > t
    2 as
    (3)
    4. Select q 3, 3 m, 1 w, 'Ven' d
    5 double
    6 union
    7 all the
    8. Select q 2, 1 m, 3 w, d 'game '.
    9 double
    10)
    11. Select q, m, w, d, d_day
    12 years of)
    13 select y + (level - 1) d_day
    14, ceil (extract (day of cast (y + (level - 1) as timestamp)) / 7) week_7_day
    15                   , t.*
    16 of)
    17 select add_months (trunc (sysdate, 'year') (q * 3-3) +(m-1)) y
    18                             , t.*
    19 t
    20                     ) t
    21 connect
    22 by level<= last_day(y)="" -="" y="" +="">
    23 and prior y = y
    dbms_random.value (24 and prior) is not null
    25         )
    where the 26 w = week_7_day
    27 and substr (to_char (d_day 'day'), 1, 3) = lower (d);

    Q M W D D_DAY
    ---------- ---------- ---------- --- ---------
    2 1 3 Friday 18 April 13
    3 3 1 Fri 06-SEP-13

    SQL >

  • First date of the month

    Hi experts,

    Please let me know how to get registered for the 1st of the month by using the query, after passing a date in the query:

    My queries below give me 1 license of the year and the last date of the month... Kindly hep...
    SELECT TRUNC(TO_DATE('24-JUN-2011'),'YEAR') FROM DUAL
    
    SELECT LAST_DAY(ADD_MONTHS('24-JUN-2011',12 - 
    TO_NUMBER(TO_CHAR(SYSDATE,'mm')))) FROM DUAL
    Help appreciated,

    Thnx in advance
    TRUNC(TO_DATE('24-JUN-2011'),'MM')
    

    And he always will be always 1... ;)

  • How to divide the monthly amount in weeks no fracture

    Hi, I'm developing a quarterly report where there will be 13 weeks in a quarter (always) and the need to display amounts against only 13 weeks.

    First month 4 weeks, 2 months 4 weeks and 3 months was 5 weeks all the time. I have a data dimension table that will tell me the number of the week (Col1) and the number of months (col2) this week belongs to...

    My problem is that I have aggregated at the level of the month in the table amounts. I divide these monthly amounts in weekly amounts.

    My data:

    Data bucketQuantities
    01/02/201415
    01/03/20145
    01/04/20144

    Desired output:

    MonthWeekQuantities
    01/02/201414
    01/02/201424
    01/02/201434
    01/02/201443
    01/03/201452
    01/03/201461
    01/03/201471
    01/03/201481
    01/04/201491
    01/04/2014101
    01/04/2014111
    01/04/2014121
    01/04/2014130

    Thank you

    Hello

    To finish of Frank post (and using its formula), here's a way to get your results (and extend and adapt for your quarterly report):

    WITH bucket LIKE)

    SELECT ' 01 /' 02/2014 Mon, 15 amount OF double UNION ALL

    SELECT ' 01 / 03/2014 ', 5 double UNION ALL

    SELECT ' 01 /' 04/2014, 4 dual FROM

    ),

    mm AS)

    SELECT my, quantity, rownum bucket month_no

    ),

    week AS)

    N SELECT rownum FROM dual CONNECT BY level<=>

    )

    SELECT my 'months',

    ROW_NUMBER() over (ORDER BY Mon, n) 'week ',.

    WK n,

    CASE

    WHEN n<= mod="" (quantity,="" decode="" (month_no,="" 3,="" 5,="">

    THEN CEIL (quantity / DECODE (month_no, 3, 5, 4))

    ANOTHER FLOOR (amount / DECODE (month_no, 3, 5, 4))

    END "quantities".

    OF the week, mm

    WHERE month_no = 3

    OR (month_no (1,2) AND n)<=>

    )

    ORDER BY month_no, wk;

  • Every first of the month between Date1 and Date2

    I created this query... Basically, it selects the dates more low rate and high and every day during this period, he made a subquery by selecting incoming and outgoing so far.

    I need to make a selection by month, not per day. How can I change the temporary table of DAYS so that each first day of the MONTH is selected instead of DAILY


    I have this
    ---------------------
    with
    DATES in the form
    (select (select min (REC_DATE) of the STOCK) as FROM_DT, (select max (CHANGE_DATE) of STOCK_ADJUST) as DOUBLE TO_DT),
    DAYS like
    (select Connect FROM_DT + ((ROWNUM-1)) as DATES by ROWNUM DT < = ((TO_DT-FROM_DT)) + 1)

    Select
    DAYS. GTO
    (select sum (stm.qty_rec) of stock stm WHERE pnm_auto_key = 1 and STM. REC_DATE < DAYS. Pnm_auto_key GROUP BY DT) ENTERING,
    (select sum (saj.qty_adj) in stock_adjust saj
    join in-house stock stm on saj.stm_auto_key = stm.stm_auto_key
    inner join parts_master MFN on stm.pnm_auto_key = pnm.pnm_auto_key where pnm_auto_key = 1 and SAJ. CHANGE_DATE < DAYS. Group by pnm_auto_key DT) OUTGOING
    of DAYS;
    ---------------------

    I need it
    ---------------------
    with
    DATES in the form
    (select (select min (REC_DATE) of the STOCK) as FROM_DT, (select max (CHANGE_DATE) of STOCK_ADJUST) as DOUBLE TO_DT),
    MONTHS as
    xxx?

    Select
    MONTHS. GTO
    (select sum (stm.qty_rec) of stock stm WHERE pnm_auto_key = 1 and STM. REC_DATE < MONTH. Pnm_auto_key GROUP BY DT) ENTERING,
    (select sum (saj.qty_adj) in stock_adjust saj
    join in-house stock stm on saj.stm_auto_key = stm.stm_auto_key
    inner join parts_master MFN on stm.pnm_auto_key = pnm.pnm_auto_key where pnm_auto_key = 1 and SAJ. CHANGE_DATE < MONTH. Group by pnm_auto_key DT) OUTGOING
    of MONTHS;
    ---------------------

    I won't have to try to understand which shows your code not formatted, but maybe this will give you assistance...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select to_date('05/01/2008','DD/MM/YYYY') as start_dt,
      2                    to_date('05/11/2008','DD/MM/YYYY') as end_dt from dual)
      3  --
      4  select add_months(trunc(start_dt,'MM'),rownum-1) as dt
      5  from t
      6* connect by rownum <= months_between(end_dt, start_dt)+1
    SQL> /
    
    DT
    ---------
    01-JAN-08
    01-FEB-08
    01-MAR-08
    01-APR-08
    01-MAY-08
    01-JUN-08
    01-JUL-08
    01-AUG-08
    01-SEP-08
    01-OCT-08
    01-NOV-08
    
    11 rows selected.
    
    SQL>
    

    Published by: BluShadow on November 13, 2008 12:52

Maybe you are looking for

  • Problem with Vista hit the Satellite X 200 - 20 s

    Sometimes during typing on vista, it will stutter and freeze. The time is very short. Is this a problem with vista or the laptop. The T7300 Core 2 Duo 2 ghz processor.

  • Can I downgrade my ios iphone5 9.2.1?

    I want to downgrade ios 9.2.1 I want ios 9. Is this possible?  Please help me

  • Apple account inactive messages

    I am unable to iMessage on my MacBook Pro El Capitan (10.11.3) running. When I go to Messages > Preferences > accounts my apple account shows inactive. I make it active?

  • reset pulse

    I use the API C/C++ OR-DAQmx. How can I set up a counter to produce a single pulse redeclenchables? In other words, I need a pulse output, and then the pulse is generated, if a new trigger comes in, it gives the meter so that the timing of the pulse

  • Impossible to update Windows Service Pack 2 on Windows Vista Home Basic

    Hi, I tried for months to get my Windows Vista Home Basic Windows Service Pack 2 update, but whenever he reaches 100%, it says update installed and reverting changes. He also says his encountered error code 80004005 how to fix this?