Query to get records Beginning of every week

Hi
I need to all the Beginning records of every month.
Week
COUNTRY
SKU 
SKU Description
Beginning
Gross Adds
Convert To Subscribers
Churn
End
9/15/2014 - 9/21/2014
IN
4211001
Coupon
0
3
0
0
3
9/15/2014 - 9/21/2014
PH
4211001
Coupon
0
3
0
0
3
9/15/2014 - 9/21/2014
SG
4211001
Coupon
0
3
0
0
3
9/15/2014 - 9/21/2014
TH
4211001
Coupon
0
3
0
0
3
11/17/2014 - 11/23/2014
TH
0
Coupon
0
1
0
0
1
12/8/2014 - 12/14/2014
TH
0
Coupon
1
1
0
0
2
12/8/2014 - 12/14/2014
TH
4211001
Coupon
3
80
0
0
83
where i had got all the query except the beginning.
Beginning is some thing like what data is there till the starting of the week.
where my calculation is 
Consider in the week 9/15/2014 - 9/21/2014  Country= TH (Thailand) Sku code=4211001,Sku Description=Coupon  gross adds =3 , Churn=0,Convert to subscribers =0 ,End=3
On the next week ie., 12/8/2014 - 12/14/2014 the beginning should be  3 and gross adds=80 etc..
Beginning = Records till date
Gross adds = Records added this week
cancels = cancels happens this week
end =beginning+gross adds-cancels.
Can any one help me with the query.
Regards,
Rahul

Hi Guys
Can any one help me with the below senario.
<
Week
COUNTRY
SKU 
SKU Description
Beginning
Gross Adds
Convert To Subscribers
Churn
End
9/15/2014 - 9/21/2014
IN
4211001
Coupon
0
3
0
0
3
9/15/2014 - 9/21/2014
PH
4211001
Coupon
0
3
0
0
3
9/15/2014 - 9/21/2014
SG
4211001
Coupon
0
3
0
0
3
9/15/2014 - 9/21/2014
TH
4211001
Coupon
0
3
0
0
3
11/17/2014 - 11/23/2014
TH
0
Coupon
0
1
0
0
1
12/8/2014 - 12/14/2014
TH
0
Coupon
1
1
0
0
2
12/8/2014 - 12/14/2014
TH
4211001
Other
0
80
0
0
80
12/8/2014 - 12/14/2014
TH
4211002
Other
0
5
0
0
5
12/15/2014 - 12/21/2014
4211002
Other
5
2
0
0
7
12/15/2014 - 12/21/2014
TH
0
Coupon
2
2
0
0
4
12/15/2014 - 12/21/2014
TH
4211001
Other
80
38
0
0
123
12/15/2014 - 12/21/2014
TH
4211002
Coupon
0
2
0
0
2
12/15/2014 - 12/21/2014
TH
4211002
Other
7
5
0
0
12
12/22/2014 - 12/28/2014
TH
4211001
Other
123
3
0
0
126
i need to get all data on first of every week and on the next week it should get add with the previous week data .
thanks
Rahul

Similar Messages

  • Query  for getting records  max  reported  timestamp and 2nd max report

    query for getting records in between
    max reported timestamp and 2nd max reported timestamp
    HERE IS ALL RESULT SET
    TIME DOMAIN
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    PD_REPORTED_TIMESTAM PD_USER
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    PD_REPORTED_TIMESTAM PD_USER
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:25 TOMCAT
    QUERY RESULT TO COME
    TIME DOMAIN
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    Message was edited by:
    user517983

    Hi,
    can we write query like this.
    1 select pd_user,PD_REPORTED_TIMESTAMP
    2 from sp_process_detail_current spdc
    3 where host_id='DSCP02469'and pd_user='TOMCAT'
    4 and exists(
    5 select PD_REPORTED_TIMESTAMP from sp_process_detail_current
    6* having max(PD_REPORTED_TIMESTAMP)-spdc.PD_REPORTED_TIMESTAMP=0)
    SQL> /
    PD_USER PD_REPORTED_TIMESTAM
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45

  • Help to write query to get records from specified time TO specified time?

    I have a table which has large data and the table is updated every min,
    Suppose the Table comp(timeid date,sessions varchar2,sid varchar2)
    Here time needs to be checked
    So now i have to write a query which displays records that have been in the table
    for every 5 mins
    default timeframe is sysdate-5 then the lower and upper bound is multiple of 5 i.e
    Suppose now Time and sysdate: 12-sep-2007 1:22:00pm
    From sysdate: 12-sep-2007 1:15:01pm TO sysdate: 12-sep-2007 1:20:00pm
    So i need a query to get the records from 1:15:01pm to 1:20pm.
    Message was edited by:
    user594721

    Explanation is not clear.Please give sample data and expected o/p.
    If you need the data of previous five minutes, do like this...
    SQL> select id, to_char(time,'dd/mm/yyyy hh:mi:ss') time
      2  from test;
            ID TIME
             1 13/09/2007 10:29:55
             1 13/09/2007 10:29:22
             1 13/09/2007 10:20:28
    SQL> select id, to_char(time,'dd/mm/yyyy hh:mi:ss') time,
      2             to_char(sysdate,'dd/mm/yyyy hh:mi:ss') current_time
      3  from test
      4  where time between (sysdate - (5/24/60)) and sysdate;
            ID TIME                CURRENT_TIME
             1 13/09/2007 10:29:55 13/09/2007 10:32:45
             1 13/09/2007 10:29:22 13/09/2007 10:32:45                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Query for getting Last 4 Day of weeks - need help

    I am having a table profile that contains a column 'Modified_Date' that stores date values. The table contains records for the last one month.
    Now, I need a query that gives me the last 3 wednesdays (Including today)
    i.r,. I need the last 4 wednesdays including today.
    How can I acheive this.
    Thanks in advance.
    Regards
    Raghu.

    Hi,
    explain? I'll try.
    Level is a pseudocolumn used in conjunction with connect by. In connect by I used < 5 as a condition since you wanted the last 4 Wednesday. I used it to get a number to be used as a multiplier.
      1  select next_day(sysdate,'wednesday')-(7*level) weds, level lvl from dual
      2* connect by level < 5
    SQL> /
    WEDS             LVL
    06-AUG-08          1
    30-JUL-08          2
    23-JUL-08          3
    16-JUL-08          4
    next_day(p_date,'wednesday') returns the calendar date of Wednesday after the date in p_date
    (7*level) a week is composed of seven (7) days multiplied by level or number of weeks to get number of days between weeks. I then subtract this from the result of next_day function

  • Query to get records between a range...............

    Hi,
    Is there any way in oracle to get records between the records 20-30.
    As far as i know in oracle you can put where rownum < (some integer)
    But is it possible to getsomething between the records 20-30
    Thanks

    Is there any way in oracle to get records between the
    records 20-30.No you can't do it.
    The reason why it's not possible is because oracle has no internal ordering of the records.
    http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
    How ROWNUM Works
    ROWNUM is a pseudocolumn (not a real column) that is available in a query. ROWNUM will be assigned the numbers 1, 2, 3, 4, ... N, where N is the number of rows in the set ROWNUM is used with. A ROWNUM value is not assigned permanently to a row (this is a common misconception). A row in a table does not have a number; you cannot ask for row 5 from a table—there is no such thing.

  • Query to get records  starting yesterday 10PM

    Hi ,
    I have Few records in a table with corresponding time in column say x.
    Now i want to select all the records from Yesterday's 10PM to till date.I can't use sysdate or sysdate-1 .
    What is the easiest way to do this.
    Thanks
    Pramod

    DeepakDevarapalli wrote:
    i tested . its working. try this and let me know
    SELECT *
    FROM table_timestmp
    WHERE timestmp > SYSTIMESTAMP - NUMTODSINTERVAL (16, 'HOUR');
    I don't think this is what the OP required.
    SYSTIMESTAMP - NUMTODSINTERVAL (16, 'HOUR')Will return the time as of 16 hours ago, not at 10 P.M. of the previous day.

  • Query for getting data for every quarter for financial year

    Hi,
    My problem is I need to get the data for every quarter for financial year and also I need data for every week for financial year.
    For example for financial year 2012-13, Apr2012 to Jun2012 would be Q1, Jul2012 to Sep2012 would be Q2 and so on. Total 8quarters should come upto Apr2013.
    In the same way  1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
    Thanks in advance.

    lakmesri wrote:
    Hi,
    My problem is I need to get the data for every quarter for financial year and also I need data for every week for financial year.
    For example for financial year 2012-13, Apr2012 to Jun2012 would be Q1, Jul2012 to Sep2012 would be Q2 and so on. Total 8quarters should come upto Apr2013.
    In the same way  1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
    Thanks in advance.
    How can you get 8 quarters within a year ? I'b be concerned here.
    lakmesri wrote:
    Hi,
    In the same way  1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
    Thanks in advance.
    First, that question is really not clearly asked. Second how could it be urgent ? You even did not tell us your Oracle version, did not show any tables descr, output sample nor any effort on your side to work on.
    Nicolas.

  • Sql to get the Monday of every IW week in a year!

    Hi There!
    This is an SOS :) I had to get a query to give me all the Mondays of a IW week in a year. I think as per the IW weeks there are around 52.1 weeks in a year. So basically, I want the starting Monday of every week. I would then store those values in a variable and use them in APEX as column headers. Online I saw some samples not related with this, but where looping was done using the all_objects. Not sure if that is the right approach.
    The problem is since this is not stored in any table, how can I loop like 52/53 times such that the output shows all the Mondays (date format) for a given year. Basically, the output would be 52/53 rows with a date(monday of the week).
    Please help!
    thanks,
    Sun
    Edited by: ryansun on Jun 28, 2012 11:09 PM

    Would this be something you are looking for?
    SQL> variable yr number
    SQL> exec :yr := 2015
    SQL> with dates as (
      2  select to_date('0101'||:yr,'ddmmyyyy')-4+level da
      3    from dual
      4  connect by level < 373
      5  )
      6  select :yr iyyy, to_char(da,'IW') iw, da monday
      7    from dates
      8   where to_char(da,'dyiyyy', 'nls_date_language=american')='mon'||:yr
      9  ;
          IYYY IW       MONDAY
          2015 01       29-12-2014
          2015 02       05-01-2015
          2015 03       12-01-2015
          2015 04       19-01-2015
          2015 05       26-01-2015
          2015 06       02-02-2015
          2015 07       09-02-2015
          2015 08       16-02-2015
          2015 09       23-02-2015
          2015 10       02-03-2015
          2015 11       09-03-2015
          2015 12       16-03-2015
          2015 13       23-03-2015
          2015 14       30-03-2015
          2015 15       06-04-2015
          2015 16       13-04-2015
          2015 17       20-04-2015
          2015 18       27-04-2015
          2015 19       04-05-2015
          2015 20       11-05-2015
          2015 21       18-05-2015
          2015 22       25-05-2015
          2015 23       01-06-2015
          2015 24       08-06-2015
          2015 25       15-06-2015
          2015 26       22-06-2015
          2015 27       29-06-2015
          2015 28       06-07-2015
          2015 29       13-07-2015
          2015 30       20-07-2015
          2015 31       27-07-2015
          2015 32       03-08-2015
          2015 33       10-08-2015
          2015 34       17-08-2015
          2015 35       24-08-2015
          2015 36       31-08-2015
          2015 37       07-09-2015
          2015 38       14-09-2015
          2015 39       21-09-2015
          2015 40       28-09-2015
          2015 41       05-10-2015
          2015 42       12-10-2015
          2015 43       19-10-2015
          2015 44       26-10-2015
          2015 45       02-11-2015
          2015 46       09-11-2015
          2015 47       16-11-2015
          2015 48       23-11-2015
          2015 49       30-11-2015
          2015 50       07-12-2015
          2015 51       14-12-2015
          2015 52       21-12-2015
          2015 53       28-12-2015
    53 rows selected.

  • Need help in SQL query to get only distinct records

    Hi all.
    I am new to oracle SQL and i want to write a query to get only distinct values from 2 tables.
    for example i hade 2 tables table1(employee_id,employee_no,grade) and another table2 with same structure.
    for example data in table1 is
    Employeeid employeeno Grade
    1 101 A
    1 101 B
    1 101 E
    1 101 D
    and data in table 2 is
    Employeeid employeeno Grade
    1 101 A
    1 101 B
    1 101 E
    i want to display only the fourth row like the data that doesnt exist in table2 i,e (1 101 D)
    I had too much records in both tables and i jst want to see the records that is in table 1 not in table 2 only.
    employeeid and employeeno are the same in both tables
    I hope u understand my query. I user left outer join and right outer join bt it displays all the results that and matching and unmatching. I want jst unmatched records.
    Any help is highly Appreciated.
    Thanx in Advance.
    I am using oracle 10G on windows

    Try MINUS:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries004.htm#i2054381
    SQL> -- generating sample data:
    SQL> with t1 as (
      2  select 1 employeeid, 101 employeeno, 'A' grade from dual union
      3  select 1, 101, 'B' from dual union
      4  select 1, 101, 'E' from dual union
      5  select 1, 101, 'D' from dual
      6  )
      7  ,  t2 as (
      8  select 1 employeeid, 101 employeeno, 'A' grade from dual union
      9  select 1, 101, 'B' from dual union
    10  select 1, 101, 'E' from dual
    11  )
    12  --
    13  -- actual query:
    14  --
    15  select employeeid
    16  ,      employeeno
    17  ,      grade
    18  from   t1
    19  minus
    20  select employeeid
    21  ,      employeeno
    22  ,      grade
    23  from   t2;
    EMPLOYEEID EMPLOYEENO G
             1        101 D
    1 row selected.

  • How to get wage type for every time record

    Hi Pros,
          I am using DS 0CA_TS_IS_1, it includes report time type (0REPTT), but not have wage type. in CATSDB, I fied fields for attendance/absence type and wage type. but not every time record has wage type. can you please tell me how to get wage type for every time record? what is relation between reporting time type, attendance/absence type and wage typs?

    Hello,
    Can you talk to your HR/T&E functional consultant if they populate these values in CATSDB table using standard way or if there are custom fields that are in CATSDB OR any other table which can be used to meed the requirements
    Thanks
    Abhishek Shanbhigue

  • How can I get record count with a query?

    In Client/Server pplication,the client send a query to server.
    How can server get record count by oracle call interface?
    Is it need execute "select count(*) from ...."?

    Yes.
    Either that or increment a counter for each record fetched and
    loop round until you hit the last record.
    The first method would be more efficient on large datasets.

  • Query to get Weekly Report

    Hello,
    I wrote a query to get weekly report, which should start from Sunday to Saturday a typical week. for example the week is 04/03/2011 to 04/09/2011 i run the query on or Job on say on anyday of the week of 04/10/2011, 04.11.2011 etc.. here is my query, but this seems to work from the sysdate to - 7 days which doesn't get the sunday to sat requirement.. can someone please help..
    select uid, psn, TO_char(date_in,'mm/dd/yyyy')
    FROM TEST
    WHERE uid like '%ST%'
    and date_in > trunc(SYSDATE) -7
    ORDER BY date_in ASC;
    Thank you.

    789287 wrote:
    Centiful,
    Thank youvery much for your help. it works now. This should work any day of this week i run will get previous week's data right? 'IW' means ISO calenadar?Yes IW in the TRUNC function means truncate the date passed to the first day of the ISO Week (Monday).
    I made this as a procedure and created a job to run on a weekly basis. once the Job runs and gets the data into text file onto the server, i have to mail the text file to the management automatically through a dbms_scheduler. How can i send an email automatically through a Scheduler? could anyone give me an example please?Instead of creating the text file you could return the data and send it directly in a mail using UTL_MAIL
    Another alternative would be to use DBMS_SCHEDULER to invoke an external executable that could send the mail for you.

  • Query to get the records with same last name

    I need to write a single sql query to get all records with duplicate last_name's. For example, if tab1 has 4 records:
    10     Amit     Kumar
    20     Kishore          Kumar
    30     Sachin     Gupta
    40     Peter     Gabriel
    then the query should return
    10     Amit     Kumar
    20     Kishore     Kumar
    id, name,L_name being the 3 columns in table
    Apprecite you help.
    Thank you
    Mary

    SQL> create table mytable (id,name,l_name)
      2  as
      3  select 10, 'Amit', 'Kumar' from dual union all
      4  select 20, 'Kishore', 'Kumar' from dual union all
      5  select 30, 'Sachin', 'Gupta' from dual union all
      6  select 40, 'Peter', 'Gabriel' from dual
      7  /
    Table created.
    SQL> select id
      2       , name
      3       , l_name
      4    from ( select t.*
      5                , count(*) over (partition by l_name) cnt
      6             from mytable t
      7         )
      8   where cnt > 1
      9  /
                                        ID NAME    L_NAME
                                        10 Amit    Kumar
                                        20 Kishore Kumar
    2 rows selected.Regards,
    Rob.

  • How to get query from a record group

    HI
    do we get the query from which record groupis based on in oracle forms with out checking in to the properties.

    Hello,
    No, you cannot get the initial SELECT order from the Record Group.
    Francois

  • SQL query to get last 6 months records neglect the current month

    Hi All;
    I need help with 
    sql query to get last 6 months records neglect the current month
    Any help much appreciated
    Thanks
    Pradnya07

    SELECT <> FROM tbl WHERE dt >=dateadd(month,-6,GETDATE())
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

Maybe you are looking for