sum of weekly data

sum of weekly data.. from daily data.

 create table test3(tno number(10), tdate date);

declare
begin
for i in 1..20 loop
insert into test3 values(i,sysdate+i);
end loop;
end;


SELECT * FROM test3;

TNO                    TDATE                     
---------------------- ------------------------- 
1                      21-APR-11                 
2                      22-APR-11                 
3                      23-APR-11                 
4                      24-APR-11                 
5                      25-APR-11                 
6                      26-APR-11                 
7                      27-APR-11                 
8                      28-APR-11                 
9                      29-APR-11                 
10                     30-APR-11                 
11                     01-MAY-11                 
12                     02-MAY-11                 
13                     03-MAY-11                 
14                     04-MAY-11                 
15                     05-MAY-11                 
16                     06-MAY-11                 
17                     07-MAY-11                 
18                     08-MAY-11                 
19                     09-MAY-11                 
20                     10-MAY-11                 

20 rows selected


now i want sum of weekly datasum(tTNO).

Something like...

SQL> ed
Wrote file afiedt.buf

  1  with t as (select rownum as tno, sysdate+rownum as tdate from dual connect by rownum <= 20)
  2  --
  3  -- end of test data
  4  --
  5  select distinct trunc(tdate,'fmIW') as start_wk
  6        ,trunc(tdate,'fmIW')+6 as end_wk
  7        ,sum(tno) over (partition by trunc(tdate,'fmIW')) as sm
  8  from t
  9* order by 1
SQL> /

START_WK    END_WK              SM
----------- ----------- ----------
18-APR-2011 24-APR-2011         10
25-APR-2011 01-MAY-2011         56
02-MAY-2011 08-MAY-2011        105
09-MAY-2011 15-MAY-2011         39

or just a SUM of basic rather than analytical...

SQL> ed
Wrote file afiedt.buf

  1  with t as (select rownum as tno, sysdate+rownum as tdate from dual connect by rownum <= 20)
  2  --
  3  -- end of test data
  4  --
  5  select trunc(tdate,'fmIW') as start_wk
  6        ,trunc(tdate,'fmIW')+6 as end_wk
  7        ,sum(tno) as sm
  8  from t
  9  group by trunc(tdate,'fmIW')
 10* order by 1
SQL> /

START_WK    END_WK              SM
----------- ----------- ----------
18-APR-2011 24-APR-2011         10
25-APR-2011 01-MAY-2011         56
02-MAY-2011 08-MAY-2011        105
09-MAY-2011 15-MAY-2011         39

Published by: BluShadow on April 20, 2011 13:56

Tags: Database

Similar Questions

  • Annual, monthly, weekly data

    I now of tables with data, I use Oracle 11 g R2.

    CREATE TABLE GroupName
    (group_id NUMBER (8) NOT NULL,
    GroupName varchar2 (30)
    );

    insert into GroupName values (10, 'Group 1');
    insert into GroupName values (20, 'Group2');

    CREATE TABLE group_device
    (group_id NUMBER (8) NON NULL
    level_id number 4 not null
    member_id NUMBER (4) NOT NULL
    device_id NUMBER (10) NOT NULL
    , varchar2 (30) nom_peripherique
    , batch number (2)
    , install_date DATE NOT NULL
    remove_date DATE
    );

    INSERT INTO group_device (group_id, level_id, member_id, device_id, nom_peripherique, batch, install_date, remove_date) VALUES (10, 1, 1, 123, "device123", 2, TO_DATE (May 23, 2012 "," mm/dd/yyyy"), TO_DATE (May 28, 2012","mm/dd/yyyy"));
    INSERT INTO group_device (group_id, level_id, member_id, device_id, nom_peripherique, batch, install_date, remove_date) VALUES (10.2, 1, 456, "device456", 2, TO_DATE (May 28, 2012 "," mm/dd/yyyy"), TO_DATE (June 1, 2012","mm/dd/yyyy"));
    INSERT INTO group_device (group_id, level_id, member_id, device_id, nom_peripherique, batch, install_date, remove_date) VALUES (10.2, 1, 789, 'device789', 1, TO_DATE (June 1, 2012 "," mm/dd/yyyy"), null);
    INSERT INTO group_device (group_id, level_id, member_id, device_id, nom_peripherique, batch, install_date, remove_date) VALUES (10, 1, 2, 999, 'device999', 1, TO_DATE (May 4, 2012 "," mm/dd/yyyy"), TO_DATE (May 17, 2012","mm/dd/yyyy"));
    INSERT INTO group_device (group_id, level_id, member_id, device_id, nom_peripherique, batch, install_date, remove_date) VALUES (10.2, 4, 1123, "device1123", 2, TO_DATE (January 22, 2012 "," mm/dd/yyyy"), TO_DATE (January 27, 2012","mm/dd/yyyy"));
    INSERT INTO group_device (group_id, level_id, member_id, device_id, nom_peripherique, batch, install_date, remove_date) VALUES (10, 1, 4, 1456, 'device1456', 1, TO_DATE (January 27, 2012 "," mm/dd/yyyy"), TO_DATE (January 28, 2012","mm/dd/yyyy"));
    commit;


    create table (reads
    number of DEVICE_ID,
    number of ReadValue,
    date of readtimestamp);


    Insert in the values of readings (123,.51, to_date (' 05/21/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123,.61, to_date (' 05/22/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (123,.21, to_date (' 05/23/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123, 2.51, to_date (' 05/24/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123, 3.51, to_date (' 05/25/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123, 4.51, to_date (' 05/26/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123,.61, to_date (' 05/27/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123,.91, to_date (' 05/28/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (123, 4.51, to_date (' 05/29/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123, 4.51, to_date (' 05/30/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (123, 7.61, to_date (' 06/17/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123, 9.91, to_date (' 06/18/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (123, 15.51, to_date (' 06/21/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123, 101, to_date (' 05/28/2012 ',' mm/dd/yyyy'));


    Insert in the values of readings (456, 33,51, to_date (' 05/26/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (456, 23.61, to_date (' 05/27/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (456, 67.91, to_date (' 05/28/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (456, 46,51, to_date (' 05/29/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (456, 98.51, to_date (' 05/30/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (456, 34.51, to_date (' 05/31/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (456, 34.51, to_date (' 06/01/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (456, 34.51, to_date (' 06/02/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (456, 34.51, to_date (' 06/03/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (456, 34.51, to_date (' 06/04/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (456, 34.51, to_date (' 06/05/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (789, 198,51, to_date (' 05/30/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (789, 234.51, to_date (' 05/31/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (789, 334.51, to_date (' 06/01/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (789, 434.51, to_date (' 06/02/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (789, 534.51, to_date (' 06/03/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (789, 634.51, to_date (' 06/04/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (789, 734.51, to_date (' 06/05/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (789, 222.51, to_date (' 06/06/2012 ',' mm/dd/yyyy'));


    Insert in the values of readings (123,.51, to_date (' 05/01/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (123,.61, to_date (' 05/02/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (999, 4.21, to_date (' 05/03/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (999, 25.51, to_date (' 05/04/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (999, 33,51, to_date (' 05/05/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (999, 44.51, to_date (' 05/06/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (999, 78,61, to_date (' 05/17/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (999, 98,91, to_date (' 05/18/2012 ',' mm/dd/yyyy'));



    Insert in the values of readings (1123, 91.51, to_date (' 01/21/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1123, 94.61, to_date (' 01/22/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (1123, 99,21, to_date (' 01/23/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1123, 72.51, to_date (' 01/24/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1123, 53.51, to_date (' 01/25/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1123, 44.51, to_date (' 01/26/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1123, 99.61, to_date (' 01/27/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1123, 105.91, to_date (' 01/28/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (1123, 204.51, to_date (' 01/29/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1123, 464.51, to_date ('01 2012 30', ' mm/dd/yyyy'));

    Insert in the values of readings (1456, 733.51, to_date (' 01/26/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1456, 823.61, to_date (' 01/27/2012 ',' mm/dd/yyyy'));

    Insert in the values of readings (1456, 967.91, to_date (' 01/28/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1456, 346.51, to_date (' 01/29/2012 ',' mm/dd/yyyy'));
    Insert in the values of readings (1456, 398.51, to_date ('01 2012 30', ' mm/dd/yyyy'));



    commit;


    I wrote the following question.

    Select elgl.groupname,
    TO_CHAR (to_date ('01' |)) Mo. Month_Number | ((' ' 2012 ', 'DDMMYYYY'), 'MM') as Month_name,.
    NVL ((select sum (nvl(cr.readvalue,0))
    reads cr, group_device, el GroupName
    where cr.device_id = eh.device_id
    and cr.device_id in (eh.device_id)
    and eh.level_id = 1
    and el.group_id = eh.group_id
    and el.groupname = elgl.groupname
    and Trunc (cr.readtimestamp, 'MM') = To_Date ('01' |) Mo. Month_Number | (((' ' 2012 ', 'DDMMYYYY')), 0) Readvalue.
    NVL ((select sum (nvl(cr.readvalue,0)) of reads cr, group_device, el groupname))
    where cr.device_id = eh.device_id
    and cr.device_id in (eh.device_id)
    and eh.level_id = 2
    and el.group_id = eh.group_id
    and el.groupname = elgl.groupname and Trunc (cr.readtimestamp, 'MM') = To_Date ('01' |) Mo. Month_Number | (((' ' 2012 ', 'DDMMYYYY')), 0) Grouptotal,.
    NVL (((select sum (nvl(cr.readvalue,0))
    reads cr, group_device, el GroupName
    where cr.device_id = eh.device_id
    and cr.device_id in (eh.device_id)
    and eh.level_id = 1
    and el.group_id = eh.group_id
    and el.groupname = elgl.groupname
    and Trunc (cr.readtimestamp, 'MM') = To_Date ('01' |) Mo. Month_Number | ((' ' 2012 ', 'DDMMYYYY')).
    (by selecting sum (nvl(cr.readvalue,0)) reads cr, group_device, el groupname)
    where cr.device_id = eh.device_id
    and cr.device_id in (eh.device_id)
    and eh.level_id = 2
    and el.group_id = eh.group_id
    and el.groupname = elgl.groupname and Trunc (cr.readtimestamp, 'MM') = To_Date ('01' |) Mo. Month_Number | ((((' ' 2012 ', 'DDMMYYYY'))), '0') Diff,.
    round (((select sum (nvl(cr.readvalue,0))
    reads cr, group_device, el GroupName
    where cr.device_id = eh.device_id
    and cr.device_id in (eh.device_id)
    and eh.level_id = 1
    and el.group_id = eh.group_id
    and el.groupname = elgl.groupname
    and Trunc (cr.readtimestamp, 'MM') = To_Date ('01' |) Mo. Month_Number | (((' ' 2012 ', 'DDMMYYYY'))).
    (by selecting sum (nvl(cr.readvalue,0)) reads cr, group_device, el groupname)
    where cr.device_id = eh.device_id
    and cr.device_id in (eh.device_id)
    and eh.level_id = 2
    and el.group_id = eh.group_id
    and el.groupname = elgl.groupname and Trunc (cr.readtimestamp, 'MM') = To_Date ('01' |) Mo. Month_Number | (((((' ' 2012 ', 'DDMMYYYY'))) * 100), 3) by
    of the LLNA GroupName, (select lpad(level,2,'0') from dual connect by level month_number < = 12) MB
    order of elgl.groupname, month_name;


    gives me suite out -.

    Group 1 01 3270,05 1330.4 1939,65 245.794
    Group 1 02 0 0 0
    Group 1 03 0 0 0
    Group 1 04 0 0 0
    Group 1 05 409.78 737, 58 - 327.8 55.557
    Group 1 06 33.03 3067, 61 - 3034.58 1.077
    Group 1-07 0 0 0
    Group 1-08 0 0 0
    Group 1-09 0 0 0
    Group 1 10 0 0 0
    Group 1 11 0 0 0
    Group 1 12 0 0 0


    Which is good, but I think that this query is very complicated instead I'm looking for better query that can give me a similar output. This request is also for the year, but I need for the week and month.
    GroupName | Name of the month | ReadValue | Total Group | Difference | Percentage - exit 1 of the request
    GroupName | Name of the week | ReadValue | Total Group | Difference | Percentage - result of application 2
    GroupName | Name of the day | ReadValue | Total Group | Difference | Percentage - exit 3 of the application

    Thank you

    For percentage his right just not. It should come as - *(readvalue-grouptotal) /readvalue) * 100

    The part of my calculation of the PCT in the query is:

    ROUND(readvalue / grouptotal, 2)
    

    Do you really need my help to change this calculation to return (readvalue grouptotal) / readvalue) * 100?

    I will note that when I corrected the error "divisor is equal to zero", I was obviously pressed / not paying attention. I tacked on an extra DECODING when all I had to do was to change the existing. Should have been just:

    DECODE(grouptotal, 0, 0, ROUND(readvalue / grouptotal, 2)) AS PCT
    

    Remember, DECODE will have to be changed when you change the calculation to meet your needs.

  • OR the week, date of the poster

    Hello!

    Given that I contacted NOR and received no answer till now maybe some of us could help me here.

    For the week, OR what the policy for posters?

    I presented a poster for the academic session OR week but did not get any what resolution to date, so I wonder how it exactly works. Is there a date to which they say they will accept it or all the posters are automatically accepted?

    Thank you!

    According to the bottom of this page, the presentations are due July 11, 2009.

    I think that you get will be announced some time after that date.

  • How to get weekly data in OBIEE

    I had a requirement to extract the data each week for 10 weeks, please let me know how to apply this logic in RPD.

    Am using OBIEE 11 G

    Thank you

    Nadia.

    Hello Nadia,.

    Try to use the Pivot table view, it will regroup by the measure.

    What happened to your last thread? Is it resolved?

    Thank you

    Sasi nanou...

  • SQL to generate the last weeks date (not a stored procedure)

    I need SQL to generate the last dates of weeks from Monday to Sunday. I don't want to use the data in the table or the stored procedure. I need inline SQL. Please help me with your suggestions. Thanks in advance for the help.

    Varun says:
    I need SQL to generate the last dates of weeks from Monday to Sunday. I don't want to use the data in the table or the stored procedure. I need inline SQL. Please help me with your suggestions. Thanks in advance for the help.

    below should help you get started

      1* SELECT SYSDATE-LEVEL from dual CONNECT BY LEVEL < 8
    SQL> /
    
    SYSDATE-L
    ---------
    21-APR-13
    20-APR-13
    19-APR-13
    18-APR-13
    17-APR-13
    16-APR-13
    15-APR-13
    
    7 rows selected.
    
  • End of week date calculates dates in table questions

    Hello all,.

    I'm working on a document of LiveCycle Designer ES4 with a week ending the Date MM-DD-YYYY (which must always be a Saturday) selected in a subform.

    I need this end Date to then calculate and display the selected week Saturday and the previous days in a subform with a table. Day wish to view in separate columns in the header.

    sample.png

    That's what I have so far:

      TopmostSubform.Page1.Requestor.WeekEndDate::exit - (FormCalc, client)
     
    var endDate = Date2Num($,"MM-DD-YYYY")
    var dayOfWeek = Num2Date(endDate, "E")
     
    if (dayOfWeek <> 7) then
       xfa.host.messageBox("Ending date must be a Saturday")
       $ = null
       xfa.host.setFocus("$")
    endif
     
    Page1.#subform[1].InputTable.Row1[0].Date7 = Num2Date(endDate - 0, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date6 = Num2Date(endDate - 1, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date5 = Num2Date(endDate - 2, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date4 = Num2Date(endDate - 3, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date3 = Num2Date(endDate - 4, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date2 = Num2Date(endDate - 5, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date1 = Num2Date(endDate - 6, "DD")
    

    However I get an error on the WeekEndDate when selecting a Saturday.

    Someone has an idea what I am doing wrong?

    Thanks for any help!

    -Michelle

    Well, I never got an answer on the forum here, but to help others - here's what I did:

    All this was done FormCalc.

    The Date/time of WeekEndDate field object has a set model date {MM/DD/YYYY} in the field object model in LiveCycle.

    BUT, the script required the pattern to be YYYY-MM-DD

    Why? I have no idea of reversal. Another way will not work for me.

    This article also requires a Date Saturday to choose. Days of the week are identified by numbers (Sunday = 1, Monday = 2, etc.).

    The line <> 7 means that if the day is Saturday (7), then the error message "end date must be a Saturday" is displayed.

    It's the Exit Script event:

    TopmostSubform.Page1.Requestor. WeekEndDate:output- (FormCalc, client)
    var endDate = Date2Num ("$,"YYYY-MM-DD"")
    var dayOfWeek = Num2Date (endDate, "E")

    If (dayOfWeek <> 7) then
    xfa.host.messageBox ("end date must be a Saturday")
    $ = null
    xfa.host.setFocus("$")
    endif

    The different elements of the Date are set to a Date/time field without cause defined in the configuration of the field object in LiveCycle.

    Coding below means the form MM/DD .

    Each field has it's own script, with any less calculation -#

    This is the calculation for the Sunday cell script:

    . TopmostSubform.Page1 #subform [1]. InputTable.Row1 [0]. Date1: calculate - (FormCalc, client)
    dateNum var = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY") -6
    $.rawValue = num2date (dateNum,"MM/DD" ")

    And the cell Saturday, needed to display the Date of end of Saturday has the following Script, with NO less number:

    . TopmostSubform.Page1 #subform [1]. InputTable.Row1 [0]. Date7: calculate - (FormCalc, client)

    dateNum var = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY")

    $.rawValue = num2date (dateNum,"MM/DD" ")

    Why was it here?

    Because this entire project was gawd-awful, and I hope that these ideas can help another designer of forms of struggle to understand the FormCalc scripting used.

    M

  • The sum of the Date

    Hello

    I have a table with a column of end_of_week as well as Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday columns.
    I want to be able to query the data based on any date I entered (not necessarily the date of end_of_week) and the sum of the days back.
    For example:
    End_of_week  sunday  monday    tuesday    wednesday   thursday    friday      saturday
    08/20/2011    15     5         5          1           2           3           1
    08/27/2011    0      12        2          0           0           0           0
    Select sum (Sunday + Monday + Tuesday + Wednesday + Thursday + Friday + Saturday)
    "where end_of_week between August 16, 2011 '-August 27, 2011"


    This returns the wrong data because it does not recognize the days on dates. It sums up Sunday - Saturday and not the 16th (tuesday) in the 27th.

    Any help is appreciated.
    with t as (
               select date '2011-08-20' End_of_week,15 sunday,5 monday,5 tuesday,1 wednesday,2 thursday,3 friday,1 saturday from dual union all
               select date '2011-08-27' End_of_week,0 sunday,12 monday,2tuesday,0 wednesday,0thursday,0 friday,0 saturday from dual
              )
    -- end of on-the-fly data sample
    select  end_of_week,
            sum(
                case when End_of_week - 6 between date '2011-08-16' and date '2011-08-27' then sunday else 0 end +
                case when End_of_week - 5 between date '2011-08-16' and date '2011-08-27' then monday else 0 end +
                case when End_of_week - 4 between date '2011-08-16' and date '2011-08-27' then tuesday else 0 end +
                case when End_of_week - 3 between date '2011-08-16' and date '2011-08-27' then wednesday else 0 end +
                case when End_of_week - 2 between date '2011-08-16' and date '2011-08-27' then thursday else 0 end +
                case when End_of_week - 1 between date '2011-08-16' and date '2011-08-27' then friday else 0 end +
                case when End_of_week between date '2011-08-16' and date '2011-08-27' then saturday else 0 end
               ) total
      from  t
      where end_of_week between date '2011-08-16' and date '2011-08-27'
      group by end_of_week
    /
    
    END_OF_WE      TOTAL
    --------- ----------
    20-AUG-11         12
    27-AUG-11         14
    
    SQL> 
    

    SY.

  • get the last ten weeks date value

    Hi friends,
    I have a requirement in which I need to get a list of 10 dates starting today on the same week. something similar to below but a list of all the 10 dates on the same day of the week

    Select sysdate-7 double

    output:
    2011-08-08
    2011-08-01
    2011-07-25
    2011-07-18
    2011 08-11
    2011-07-04

    and so on...

    Note: All of the above dates fall on Monday. I think I can do it using connect by clause, but need the exact syntax. I tried my best to get the result

    Please let me know.

    Ok.

    select sysdate -7*(level - 1) as dt from dual connect by level <= 11
    

    Not tested, not connected to oracle.

  • Find problems with get week Date String

    Hi gurus,

    I need to get the number of week of a particular Date String. When I use the query below.

    SQL > select to_char (to_date('01-APRIL-2010','DD_MONTH-YYYY'), 'IW') 'date' double.

    Date
    ---------------------------------------------------------------------------
    13


    But it is false. It should be 14. When I try the same thing in SQLSERVER I get 14

    SELECT DATEPART (wk, April 1, 2010 "")


    Is someone can you please tell me where I'm wrong.

    Thank you and best regards,
    Vikas Krishna

    WW No. week of year (1-53), where week 1 starts on the first day of the year and continues until the seventh day of the year.

    January 1, 2010 was a Friday so for WW each week in 2010 starts Friday and ends on Thursday. 1 April 2010 Thursday was therefore still in the 13th week. but the week number changes on April 2, 2010, which is Friday.

    SQL> select to_char(to_date('02-APRIL-2010','DD-MONTH-YYYY'),'WW') "date" from dual;
    
    da
    --
    14
    

    I guess in SQL server for "wk" started the week from Sunday to Saturday any day was on 01 Jan.
    January 3, 2010 was that a Sunday to see what week number oracle gives us for this date:

    SQL> select to_char(to_date('03-JANUARY-2010','DD-MONTH-YYYY'),'WW') "date" from dual;
    
    da
    --
    01
    

    See what sqlserver gives you for it. I do not know that sql server will give weeknumber 2 for that date because SQL server starts next week on Sunday.

  • update of column based on the sum of the data from another table

    I have two tables:

    Table1 (col1, col2, col3, col4, val1, status) Table2 (col1, col2, col3, col4, val2)

    For Table1 and Table2, column (col1, col2, col3, col4) are the primary key of composit.

    Table2 could have duplicated lines, that's why I want to group by (col1, col2, col3, col4) and sum (val2)

    After that, I want to update Table1.val1 with the value of sum (Table1.val2) where Table1.col1 = Table2.col1 and Table1.col2 = Table2.col2 and Table1.col3 = Table2.col3 and Table1.col4 = Table2.col4 and status = 'V '.

    I did something like this:

    UPDATE Table1 SET val1 = (

       

    WHERE Table1.col1 = t_sommevbrute.col1 and Table1.col2 = t_sommevbrute.col2 and Table1.col3 = t_sommevbrute.col3 and Table1.col4 = t_sommevbrute.col4)

    Could someone help me please? Thank you

    merge into table1 t1

    using (select col1, col2, col3, col4, sum (val2) val2

    from table2

    Group

    by col1, col2, col3, col4) t2

    on (t1.col1 = t2.col1 t1.col2 = t2.col2 and t1.col3 = t2.col3 and t1.col4 = t2.col4 and)

    When matched then

    update set t1.val1 = t2.val2;

  • Calculation of the sum between two dates

    Hello

    I had a requirement I need to calculate the total call volume between start and end date in the repository. Can someone help me with logic?

    Thank you

    Try this

    BOX WHEN DATE BETWEEN START_DATE AND END_DATE THEN

    END OF COUNT (CALL_VOLUME), 0 OTHERWISE.

    Thank you

    Sasi nanou...

  • Days of week dates required

    Hello

    I have a table with two columns... Start date and end date.

    Start date end date
    ******** **********
    07/03/2011 06:00 05/04/2011 06:00 (jj/mm/aaaa hh) format

    I need to display the date of each Monday and every day on Sunday between the start and end dates.
    Need help... !!

    Concerning
    Evelyne

    a way

    SQL>   WITH T
      2       AS (SELECT TO_DATE ( '3/7/2011 6:00:00 AM', 'mm/dd/yyyy hh:mi:ss AM') start_date,
      3                  TO_DATE ( '4/5/2011 6:00:00 AM', 'mm/dd/yyyy hh:mi:ss AM') end_date
      4             FROM DUAL)
      5  SELECT dt, TO_CHAR ( dt, 'fmday') day_of_week
      6    FROM (SELECT TRUNC (start_date + (LEVEL - 1)) dt
      7            FROM T
      8          CONNECT BY LEVEL <= (end_date - start_date) + 1)
      9   WHERE TO_CHAR ( dt, 'fmday') IN ('monday', 'sunday');
    
    DT        DAY_OF_WE
    --------- ---------
    07-MAR-11 monday
    13-MAR-11 sunday
    14-MAR-11 monday
    20-MAR-11 sunday
    21-MAR-11 monday
    27-MAR-11 sunday
    28-MAR-11 monday
    03-APR-11 sunday
    04-APR-11 monday
    
    9 rows selected.
    
    SQL> 
    

    G.

  • sum of a date and work days

    Hello
    How add a number of days to a date and get a date which WE and official holiday?
    Thank you.

    Hello

    See [this thread | http://forums.oracle.com/forums/message.jspa?messageID=3350877#3350877].

  • Find (weekly) missing date ranges based on the Date of submission

    Nice day:

    I have a table that contains the data with a date of presentation of the report column.  If the requirements are that each employee must submit at least 1 weekly report beginning January 1, 2015, how can I find the weekly reports missing, based on the date of submission of reports.

    The ideas that I had:

    • Left join by partition by date (range between)
    • Create a date dimension view?

    Of course, I'm not sure how to approach this dilemma without creating a query of Monster.  Sometimes the simplest queries mistake me...

    Thank you, Aqua

    Here are the DDL for the table with the information from the presentation report (example):

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

    -The DOF for Table DTS_FORM_SAMPLE

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

    CREATE TABLE 'DTS_FORM_SAMPLE '.

    (NUMBER OF 'ID',

    VARCHAR2 (20) "CLOCK_NUMBER."

    NUMBER OF 'EMP_ID,'

    NUMBER OF "REPORT_TYPE."

    DATE OF THE "SUB_DATE.

    ) ;

    /

    INSERTION of REM in DTS_FORM_SAMPLE

    TOGETHER TO DEFINE

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2896, 'XX2444', 12810,1, to_date('02-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2897, 'XX2444', 12810,1, to_date('09-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2898, 'XX2444', 12810,1, to_date('16-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2899, 'XX2444', 12810,1, to_date('23-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2900, 'XX2444', 12810,1, to_date('30-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2901, 'XX2444', 12810,1, to_date('05-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2902, 'XX2444', 12810,1, to_date('12-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2903, 'XX2444', 12810,1, to_date('19-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2904, 'XX2444', 12810,1, to_date('26-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2920, 'XX2444', 12810,1, to_date('19-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2921, 'XX2444', 12810,1, to_date('22-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2922, 'XX2444', 12810,1, to_date('05-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2923, 'XX2444', 12810,1, to_date('26-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2924, 'XX2444', 12810,1, to_date('29-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2925, 'XX2444', 12810,1, to_date('12-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2965, 'XX2444', 12810,1, to_date('30-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6970, 'XX2444', 12810,1, to_date('18-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6971, 'XX2444', 12810,1, to_date('25-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6972, 'XX2444', 12810,1, to_date('04-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6973, 'XX2444', 12810,1, to_date('11-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6978, 'XX2444', 12810,1, to_date('14-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6979, 'XX2444', 12810,1, to_date('21-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6980, 'XX2444', 12810,1, to_date('28-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6981, 'XX2444', 12810,1, to_date('07-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6948, 'XX2444', 12810,1, to_date('06-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6957, 'XX2444', 12810,1, to_date('09-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6958, 'XX2444', 12810,1, to_date('16-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6959, 'XX2444', 12810,1, to_date('23-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6960, 'XX2444', 12810,1, to_date('02-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8938, 'XX2444', 12810,1, to_date('14-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8939, 'XX2444', 12810,1, to_date('21-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8940, 'XX2444', 12810,1, to_date('28-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8941, 'XX2444', 12810,1, to_date('07-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8942, 'XX2444', 12810,1, to_date('14-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8943, 'XX2444', 12810,1, to_date('21-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8977, 'XX2444', 12810,1, to_date('04-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8978, 'XX2444', 12810,1, to_date('11-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8979, 'XX2444', 12810,1, to_date('11-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8980, 'XX2444', 12810,1, to_date('18-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8981, 'XX2444', 12810,1, to_date('18-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8982, 'XX2444', 12810,1, to_date('25-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8983, 'XX2444', 12810,1, to_date('25-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8984, 'XX2444', 12810,1, to_date('02-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8985, 'XX2444', 12810,1, to_date('02-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8953, 'XX2444', 12810,1, to_date('19-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9824, 'XX2444', 12810,1, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9825, 'XX2444', 12810,1, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9826, 'XX2444', 12810,1, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8972, 'XX2444', 12810,1, to_date('30-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8973, 'XX2444', 12810,1, to_date('30-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8974, 'XX2444', 12810,1, to_date('07-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8975, 'XX2444', 12810,1, to_date('28-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8951, 'XX2444', 12810,1, to_date('12-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8952, 'XX2444', 12810,1, to_date('19-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8954, 'XX2444', 12810,1, to_date('26-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8955, 'XX2444', 12810,1, to_date('26-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8956, 'XX2444', 12810,1, to_date('05-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8957, 'XX2444', 12810,1, to_date('05-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8958, 'XX2444', 12810,1, to_date('12-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8959, 'XX2444', 12810,1, to_date('12-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8960, 'XX2444', 12810,1, to_date('19-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8961, 'XX2444', 12810,1, to_date('19-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8962, 'XX2444', 12810,1, to_date('26-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8963, 'XX2444', 12810,1, to_date('26-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8964, 'XX2444', 12810,1, to_date('02-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8965, 'XX2444', 12810,1, to_date('02-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8966, 'XX2444', 12810,1, to_date('09-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8967, 'XX2444', 12810,1, to_date('09-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8968, 'XX2444', 12810,1, to_date('16-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8969, 'XX2444', 12810,1, to_date('16-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8970, 'XX2444', 12810,1, to_date('23-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8971, 'XX2444', 12810,1, to_date('23-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8976, 'XX2444', 12810,1, to_date('04-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8986, 'XX2444', 12810,1, to_date('09-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8987, 'XX2444', 12810,1, to_date('09-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9041, 'XX2444', 12810,1, to_date('16-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9042, 'XX2444', 12810,1, to_date('16-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9043, 'XX2444', 12810,1, to_date('23-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9044, 'XX2444', 12810,1, to_date('23-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9045, 'XX2444', 12810,1, to_date('30-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9046, 'XX2444', 12810,1, to_date('30-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9047, 'XX2444', 12810,1, to_date('06-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9048, 'XX2444', 12810,1, to_date('06-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8944, 'XX2444', 12810,1, to_date('22-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8945, 'XX2444', 12810,1, to_date('22-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8946, 'XX2444', 12810,1, to_date('29-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8947, 'XX2444', 12810,1, to_date('29-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8948, 'XX2444', 12810,1, to_date('05-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8949, 'XX2444', 12810,1, to_date('05-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8950, 'XX2444', 12810,1, to_date('12-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9527, 'XX2444', 12810,1, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9528, 'XX2444', 12810,1, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9529, 'XX2444', 12810,1, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6739, 'YY7223', 11093,8, to_date('15-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6740, 'YY7223', 11093,8, to_date('21-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6741, 'YY7223', 11093,8, to_date('22-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6742, 'YY7223', 11093,8, to_date('25-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6743, 'YY7223', 11093,8, to_date('26-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6744, 'YY7223', 11093,8, to_date('27-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6745, 'YY7223', 11093,1, to_date('04-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6746, 'YY7223', 11093,1, to_date('11-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6747, 'YY7223', 11093,1, to_date('18-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6748, 'YY7223', 11093,1, to_date('25-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6749, 'YY7223', 11093,11, to_date('01-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6750, 'YY7223', 11093,11, to_date('15-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6751, 'YY7223', 11093,10, to_date('01-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11017, 'YY7223', 11093,1, to_date('07-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11018, 'YY7223', 11093,1, to_date('14-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11019, 'YY7223', 11093,1, to_date('21-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11020, 'YY7223', 11093,1, to_date('28-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11021, 'YY7223', 11093,1, to_date('04-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11022, 'YY7223', 11093,1, to_date('11-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11023, 'YY7223', 11093,1, to_date('18-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11024, 'YY7223', 11093,1, to_date('25-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11025, 'YY7223', 11093,10, to_date('31-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11026, 'YY7223', 11093,10, to_date('30-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13115, 'YY7223', 11093,1, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13201, 'YY7223', 11093,1, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13287, 'YY7223', 11093,1, to_date('27-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13373, 'YY7223', 11093,10, to_date('08-SEP-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13489, 'YY7223', 11093,8, to_date('01-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13490, 'YY7223', 11093,8, to_date('02-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13491, 'YY7223', 11093,8, to_date('03-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13492, 'YY7223', 11093,8, to_date('04-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13493, 'YY7223', 11093,8, to_date('05-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13494, 'YY7223', 11093,8, to_date('06-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13495, 'YY7223', 11093,8, to_date('07-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13496, 'YY7223', 11093,8, to_date('08-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13497, 'YY7223', 11093,8, to_date('09-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13498, 'YY7223', 11093,8, to_date('10-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13499, 'YY7223', 11093,8, to_date('11-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13500, 'YY7223', 11093,8, to_date('12-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13501, 'YY7223', 11093,8, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13502, 'YY7223', 11093,8, to_date('14-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13503, 'YY7223', 11093,8, to_date('15-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13504, 'YY7223', 11093,8, to_date('16-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13505, 'YY7223', 11093,8, to_date('17-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13506, 'YY7223', 11093,8, to_date('18-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13507, 'YY7223', 11093,8, to_date('19-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13508, 'YY7223', 11093,8, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13509, 'YY7223', 11093,8, to_date('21-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13510, 'YY7223', 11093,8, to_date('22-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13511, 'YY7223', 11093,8, to_date('23-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13512, 'YY7223', 11093,8, to_date('24-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13513, 'YY7223', 11093,8, to_date('25-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13514, 'YY7223', 11093,8, to_date('26-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13515, 'YY7223', 11093,8, to_date('27-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13516, 'YY7223', 11093,8, to_date('28-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13517, 'YY7223', 11093,8, to_date('29-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13518, 'YY7223', 11093,8, to_date('30-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13519, 'YY7223', 11093,8, to_date('31-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13030, 'YY7223', 11093,1, to_date('06-AUG-15','DD-MON-RR'));

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

    -Table DTS_FORM_SAMPLE constraints

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

    CHANGE ALTER TABLE 'DTS_FORM_SAMPLE' ('ID' ENABLE NOT NULL);

    /

    Or more simple:

    Select emp_id, w.wk, to_char (wk, 'ww') x

    from (select trunc (date ' 2015-01-01' + 7 * (level - 1), 'ww') wk)

    of the double

    connect by level<=>

    ) o

    left outer join

    s dts_form_sample

    by (emp_id) partition

    We trunc (s.sub_date, 'ww') = w.wk

    where sub_date is null

    order to emp_id,

    x

    /

    EMP_ID WK X
    ---------- --------- --
    11093 1ST JANUARY 15 01
    11093 8 JANUARY 15 02
    11093 15 JANUARY 15 03
    11093 22 JANUARY 15 04
    11093 29 JANUARY 15 05
    11093 5 FEBRUARY 15 06
    11093 12 FEBRUARY 15 07
    11093 19 FEBRUARY 15 08
    11093 26 FEBRUARY 15 09
    11093 5 MARCH 15 10
    11093 12 MARCH 15 11

    EMP_ID WK X
    ---------- --------- --
    11093 19 MARCH 15 12
    11093 26 MARCH 15 13
    11093 2 APRIL 15 14
    11093 9 APRIL 15 15
    11093 16 APRIL 15 16
    11093 23 APRIL 15 17
    11093 30 APRIL 15 18
    11093 37 15 - SEP - 10
    17-SEVEN 11093.-15 38
    24-SEVEN 11093.-15 39
    11093 1 OCTOBER 15 40

    EMP_ID WK X
    ---------- --------- --
    11093 8 OCTOBER 15 41
    11093 15 OCTOBER 15 42
    11093 22 OCTOBER 15 43
    11093 29 OCTOBER 15 44
    11093 5 NOVEMBER 15 45
    11093 12 NOVEMBER 15 46
    11093 19 NOVEMBER 15 47
    11093 26 NOVEMBER 15 48
    11093 3 DECEMBER 15 49
    11093 10 DECEMBER 15 50
    11093 17 DECEMBER 15 51

    EMP_ID WK X
    ---------- --------- --
    11093 24 DECEMBER 15 52
    11093 31 DECEMBER 15 53
    12810 1ST JANUARY 15 01
    12810 8 JANUARY 15 02
    12810 15 JANUARY 15 03
    12810 27 AUGUST 15 35
    12810 15 - SEP - 03 36
    12810 37 15 - SEP - 10
    17-SEVEN 12810.-15 38
    24-SEVEN 12810.-15 39
    12810 1 OCTOBER 15 40

    EMP_ID WK X
    ---------- --------- --
    12810 8 OCTOBER 15 41
    12810 15 OCTOBER 15 42
    12810 22 OCTOBER 15 43
    12810 29 OCTOBER 15 44
    12810 5 NOVEMBER 15 45
    12810 12 NOVEMBER 15 46
    12810 19 NOVEMBER 15 47
    12810 26 NOVEMBER 15 48
    12810 3 DECEMBER 15 49
    12810 10 DECEMBER 15 50
    12810 17 DECEMBER 15 51

    EMP_ID WK X
    ---------- --------- --
    12810 24 DECEMBER 15 52
    12810 31 DECEMBER 15 53

    57 selected lines.

    SQL >

    However OP question must answer is start of week date.

    SY.

  • 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

Maybe you are looking for