Branching row to Monthly from (Monthly, Quarterly, Yearly)

Hello all,
I ended up having another problem, which is exact reverse of the problem posted by me earlier, more info is at:
Re: Consolidating rows
Consider following input data set:
CREATE TABLE SABEGH_TEST
PRODUCT VARCHAR2(100),
TRADE_DATE DATE,
PROMPT VARCHAR(30),
PERIOD VARCHAR(10),
PRICE DECIMAL(8,2)
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PROMPT','2012-04',34.75);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PM+1','2012-05',34.25);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PQ','2012-Q2',34.35);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PQ+1','2012-Q3',34.25);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PQ+2','2012-Q4',34.75);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PY','2013-CY',40);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PQ+3','2013-Q1',39.25);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PQ+4','2013-Q2',39.75);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PQ+5','2013-Q3',40.25);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PQ+6','2013-Q4',40.75);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PY+1','2014-CY',42.5);
INSERT INTO SABEGH_TEST VALUES ('A',TRUNC(SYSDATE),'PY+2','2015-CY',44.75);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PROMPT','2012-04',58.25);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PM+1','2012-05',58.75);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PQ','2012-Q2',58.63);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PQ+1','2012-Q3',59.75);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PQ+2','2012-Q4',61.85);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PY','2013-CY',68.64);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PQ+3','2013-Q1',64.55);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PQ+4','2013-Q2',67.4);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PQ+5','2013-Q3',70.05);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PQ+6','2013-Q4',72.55);
INSERT INTO SABEGH_TEST VALUES('B',TRUNC(SYSDATE),'PY+1','2014-CY',75.64);
INSERT INTO SABEGH_TEST VALUES ('B',TRUNC(SYSDATE),'PY+2','2015-CY',78.14);
So basically, the table contains Prices of a Product starting from Apr, 2012 going forward to Dec, 2015. If the price is same between consecutive months, those rows are merge into Quarters, Year and so on.
i would like to have following output.
A, 2012-04, 34.75
A, 2012-05, 34.25
A, 2012-06, 34.35
A, 2012-07, 35.25
A, 2012-08, 35.25
A, 2012-09, 35.25
A, 2012-10, 35.75
A, 2012-11, 35.75
A, 2012-12, 35.75
A, 2013-01, 39.25
A, 2013-02, 39.25
A, 2013-03, 39.25
A, 2013-04, 39.75
A, 2013-05, 39.75
A, 2013-06, 39.75
A, 2013-07, 40.25
A, 2013-08, 40.25
A, 2013-09, 40.25
A, 2013-10, 40.75
A, 2013-11, 40.75
A, 2013-12, 40.75
A, 2014-01, 42.5
A, 2014-02, 42.5
A, 2014-03, 42.5
A, 2014-04, 42.5
A, 2014-05, 42.5
A, 2014-06, 42.5
A, 2014-07, 42.5
A, 2014-08, 42.5
A, 2014-09, 42.5
A, 2014-10, 42.5
A, 2014-11, 42.5
A, 2014-12, 42.5
A, 2015-01, 44.75
A, 2015-02, 44.75
A, 2015-03, 44.75
A, 2015-04, 44.75
A, 2015-05, 44.75
A, 2015-06, 44.75
A, 2015-07, 44.75
A, 2015-08, 44.75
A, 2015-09, 44.75
A, 2015-10, 44.75
A, 2015-11, 44.75
A, 2015-12, 44.75
So let me explain, how I got this o/p.
The first and second insert statement has data for month 2012-04 and 2012-05, the third statement now contains row for Quarter (Q2), which is Apr, May and Jun; Since we already covered Apr and May, only Jun is left, so we assign 34.35 to 2012-06. Similarly we split Q1 (Jan, Feb, Mar) , Q3 (Jul, Aug, Sep) and Q4 (Oct, Nov, Dec). One thing to watch out is the row containing column PROMPT value as ‘PY’, this row has the average prices for all quarter (Q1 through Q4) for that year (2013-CY), in this example.
The table contains multiple PRODUCTS per TRADE_DATE.
Let me know, if you need more clarifications,
Sabegh
Edited by: getsaby on Jun 23, 2012 4:44 PM

Thanks for your prompt reply. I am really sorry, if i was not clear with my question, so lets, start from the scratch. I am using Oracle 11g. Just to make it simple I used trunc(sysdate) for column TRADE_DATE. But the below data set now contains hard-coded date.
CREATE TABLE SABEGH_TEST
PRODUCT VARCHAR2(100),
TRADE_DATE DATE,
PROMPT VARCHAR(30),
PERIOD VARCHAR(10),
PRICE DECIMAL(8,2)
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PROMPT','2012-04',34.75);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PM+1','2012-05',34.25);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PQ','2012-Q2',34.35);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PQ+1','2012-Q3',34.25);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PQ+2','2012-Q4',34.75);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PY','2013-CY',40);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PQ+3','2013-Q1',39.25);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PQ+4','2013-Q2',39.75);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PQ+5','2013-Q3',40.25);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PQ+6','2013-Q4',40.75);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PY+1','2014-CY',42.5);
INSERT INTO SABEGH_TEST VALUES ('A',14-JUN-2012,'PY+2','2015-CY',44.75);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PROMPT','2012-04',58.25);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PM+1','2012-05',58.75);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PQ','2012-Q2',58.63);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PQ+1','2012-Q3',59.75);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PQ+2','2012-Q4',61.85);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PY','2013-CY',68.64);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PQ+3','2013-Q1',64.55);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PQ+4','2013-Q2',67.4);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PQ+5','2013-Q3',70.05);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PQ+6','2013-Q4',72.55);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PY+1','2014-CY',75.64);
INSERT INTO SABEGH_TEST VALUES ('B',14-JUN-2012,'PY+2','2015-CY',78.14);
The required output is as follows, and this will be store in some table for reporting purposes.
PRODUCT, TRADE_DATE, PERIOD , PRICE
A,      14-JUN-2012 , 2012-04, 34.75
A,      14-JUN-2012 , 2012-05, 34.25
A,      14-JUN-2012 , 2012-06, 34.35
A,      14-JUN-2012 , 2012-07, 35.25
A,      14-JUN-2012 , 2012-08, 35.25
A,      14-JUN-2012 , 2012-09, 35.25
A,      14-JUN-2012 , 2012-10, 35.75
A,      14-JUN-2012 , 2012-11, 35.75
A,      14-JUN-2012 , 2012-12, 35.75
A,      14-JUN-2012 , 2013-01, 39.25
A,      14-JUN-2012 , 2013-02, 39.25
A,      14-JUN-2012 , 2013-03, 39.25
A,      14-JUN-2012 , 2013-04, 39.75
A,      14-JUN-2012 , 2013-05, 39.75
A,      14-JUN-2012 , 2013-06, 39.75
A,      14-JUN-2012 , 2013-07, 40.25
A,      14-JUN-2012 , 2013-08, 40.25
A,      14-JUN-2012 , 2013-09, 40.25
A,      14-JUN-2012 , 2013-10, 40.75
A,      14-JUN-2012 , 2013-11, 40.75
A,      14-JUN-2012 , 2013-12, 40.75
A,      14-JUN-2012 , 2014-01, 42.5
A,      14-JUN-2012 , 2014-02, 42.5
A,      14-JUN-2012 , 2014-03, 42.5
A,      14-JUN-2012 , 2014-04, 42.5
A,      14-JUN-2012 , 2014-05, 42.5
A,      14-JUN-2012 , 2014-06, 42.5
A,      14-JUN-2012 , 2014-07, 42.5
A,      14-JUN-2012 , 2014-08, 42.5
A,      14-JUN-2012 , 2014-09, 42.5
A,      14-JUN-2012 , 2014-10, 42.5
A,      14-JUN-2012 , 2014-11, 42.5
A,      14-JUN-2012 , 2014-12, 42.5
A,      14-JUN-2012 , 2015-01, 44.75
A,      14-JUN-2012 , 2015-02, 44.75
A,      14-JUN-2012 , 2015-03, 44.75
A,      14-JUN-2012 , 2015-04, 44.75
A,      14-JUN-2012 , 2015-05, 44.75
A,      14-JUN-2012 , 2015-06, 44.75
A,      14-JUN-2012 , 2015-07, 44.75
A,      14-JUN-2012 , 2015-08, 44.75
A,      14-JUN-2012 , 2015-09, 44.75
A,      14-JUN-2012 , 2015-10, 44.75
A,      14-JUN-2012 , 2015-11, 44.75
A,      14-JUN-2012 , 2015-12, 44.75
B,      14-JUN-2012 , 2012-04, 58.25
B,      14-JUN-2012 , 2012-05, 58.75
B,      14-JUN-2012 , 2012-06, 58.63
B,      14-JUN-2012 , 2012-07, 59.75
B,      14-JUN-2012 , 2012-08, 59.75     
B,      14-JUN-2012 , 2012-09, 59.75     
B,      14-JUN-2012 , 2012-10, 61.85     
B,      14-JUN-2012 , 2012-11, 61.85     
B,      14-JUN-2012 , 2012-12, 61.85     
B,      14-JUN-2012 , 2013-01, 64.55     
B,      14-JUN-2012 , 2013-02, 64.55     
B,      14-JUN-2012 , 2013-03, 64.55     
B,      14-JUN-2012 , 2013-04, 67.4     
B,      14-JUN-2012 , 2013-05, 67.4     
B,      14-JUN-2012 , 2013-06, 67.4     
B,      14-JUN-2012 , 2013-07, 70.05
B,      14-JUN-2012 , 2013-08, 70.05
B,      14-JUN-2012 , 2013-09, 70.05
B,      14-JUN-2012 , 2013-10, 72.55
B,      14-JUN-2012 , 2013-11, 72.55
B,      14-JUN-2012 , 2013-12, 72.55
B,      14-JUN-2012 , 2014-01, 75.64
B,      14-JUN-2012 , 2014-02, 75.64
B,      14-JUN-2012 , 2014-03, 75.64
B,      14-JUN-2012 , 2014-04, 75.64
B,      14-JUN-2012 , 2014-05, 75.64
B,      14-JUN-2012 , 2014-06, 75.64
B,      14-JUN-2012 , 2014-07, 75.64
B,      14-JUN-2012 , 2014-08, 75.64
B,      14-JUN-2012 , 2014-09, 75.64
B,      14-JUN-2012 , 2014-10, 75.64
B,      14-JUN-2012 , 2014-11, 75.64
B,      14-JUN-2012 , 2014-12, 75.64
B,      14-JUN-2012 , 2015-01, 78.14
B,      14-JUN-2012 , 2015-02, 78.14
B,      14-JUN-2012 , 2015-03, 78.14
B,      14-JUN-2012 , 2015-04, 78.14
B,      14-JUN-2012 , 2015-05, 78.14
B,      14-JUN-2012 , 2015-06, 78.14
B,      14-JUN-2012 , 2015-07, 78.14
B,      14-JUN-2012 , 2015-08, 78.14
B,      14-JUN-2012 , 2015-09, 78.14
B,      14-JUN-2012 , 2015-10, 78.14
B,      14-JUN-2012 , 2015-11, 78.14
B,      14-JUN-2012 , 2015-12, 78.14
I still didn't understand what you meant by "You still haven't explained how the various columns in your table affect the results", based upon the output data, i don't think any columns will affect the results. I am just interested in the above output format, with those four columns (PRODUCT, TRADE_DATE, PERIOD, PRICES)
Thanks,
Sabegh

Similar Messages

  • Regarding Date data in the format of WEEKLY , MONTHLY , QUARTERLY , YEARLY

    hai
    i have one Infoobject(ZDATE) which is created based on the Reference Characteristic(ocalday) and contains data in the YYYYMMDD format.
    I want same date data in weekly , monthly , quarterly and yearly.
    So for this one i need to created ZWEEK , ZMONTH, ZQUARTER and ZYEAR infoobjects by using Reference Characteristics 0calweek , 0calmonth , 0calquarter , 0calyear and i need to write the formula for these InfoObjects for converting & getting data from the ZDATE.
    So please give the formulas for each InfoObject.
    I will assign the points
    bye
    rizwan

    Hi ,
    Try this for month and year in Transfer structure .
    zyear = zdate+0(4).
    zmonth = zdate+4(2).
    For quarter since it will be depend of what kind of fiscal period you are using.. say for ex april - march.
    For Week... whether you want find it based on calender year or fiscal period.
    Regards
    Balaji

  • Logic for monthly quarterly yearly basis for  ar eport

    hi ,
              i need to run a report (which shows sales order number and creation date
    based on erdat entered in selection screen)
    in back ground. for that i have to develop a wrapper program which calls the main program and executes it. i can do that but the thing is i need logic to run that wrapper program to execute the report on basis of monthly quarterly and yearly.
    example : if i execute the report for erdat-creation date range 15.01.2005 and 25.03.2005 we will display sales order num and date b/w this range.
    if i excute this thro wrapper program for entered date and select monthly basis,
    it should split into 3 variants i,e for  3 months and execute .what is the logic for that.

    hi ,
              i need to run a report (which shows sales order number and creation date
    based on erdat entered in selection screen)
    in back ground. for that i have to develop a wrapper program which calls the main program and executes it. i can do that but the thing is i need logic to run that wrapper program to execute the report on basis of monthly quarterly and yearly.
    example : if i execute the report for erdat-creation date range 15.01.2005 and 25.03.2005 we will display sales order num and date b/w this range.
    if i excute this thro wrapper program for entered date and select monthly basis,
    it should split into 3 variants i,e for  3 months and execute .what is the logic for that.

  • Is there a way to change the date format so that delegates have to choose a day, month and year from a drop down menu as my delegates keep forgetting to change the year of their information

    When my delegates are filling in a event form i have put together, a large number of them forget to change either the month or year on the date field. Is there a way to have a date field that has drop down boxes for day, month and year so they have to choose rather than a date been already on the screen??
    Thanks

    Hi Christopher,
    The WEEKDAY function allows specifying either Sunday or Monday as the first day of the week:
    WEEKDAY
    The WEEKDAY function returns a number that is the day of the week for a given date. WEEKDAY(date, first-day)
      date:  The date the function should use. date is a date/time value. The time portion is ignored by this function.
      first-day: An optional value that specifies how days are numbered.
    Sunday is 1 (1 or omitted):  Sunday is the first day (day 1) of the week and Saturday is day 7.
    Monday is 1 (2):  Monday is the first day (day 1) of the week and Sunday is day 7. Monday is 0 (3):  Monday is the first day (day 0) of the week and Sunday is day 6.
    But I think you are referring to the first day of the 'workweek', for which I do not see a means of defining a custom value.
    Since you want to 'insert categories', though, you could easily define your own, using WEEKDAY(date) or WEEKDAY(date,1), plus an IF statement to return the category label appropriate to the day. Here's one for a Sunday to Thursday work week. Dates are in column A, the formula is in whichever column you want as the Category column. For the example, I've placed it in column B.
    B2, and filled down: =IF(WEEKDAY(A)<6,"Work","Off")
    The top table shows the weekday numbers returned for each day of the week for each of the three permitted values for the optional second argument. The bottom table shows the results from the formula above, used to define a category label for each date:
    A10 was left blank intentionally, to determine if the lack of data resulted in an error. The Warning message, flagged by the blue 'warning' triangle, is "The formula uses a number in place of a date." The 'date' assigned to this numerical value of zero was a Friday, but I'm not certain when. Probably best to avoid extra rows with no date shown.
    Regards,
    Barry

  • How to get Week,Month and Year details from a date column

    Hi frenz,
    I've a column like tran_date which is a date column..... I need the next week details based on this column and so on...
    I need month and year details as well based on this tran_date column.... can any one tell me how...
    Thanks in advance

    My example for objects:
    create or replace type date_object as object
      centure number,
      year    number,
      month   number,
      day     number,
      hour    number,
      minute  number,
      second  number,
      daypart number,
      week    number,
      constructor function date_object(p_dt date)
        return SELF as result
    create or replace type body date_object is
      constructor function date_object(p_dt date)
        return SELF as result
      as
      begin
        SELF.centure:= trunc(to_char(p_dt,'YYYY')/100);
        SELF.year:=    to_char(p_dt,'YYYY');
        SELF.month:=   to_char(p_dt,'MM');
        SELF.day:=     to_char(p_dt,'DD');
        SELF.hour:=    to_char(p_dt,'HH24');
        SELF.minute:=  to_char(p_dt,'MI');
        SELF.second:=  to_char(p_dt,'SS');
        SELF.daypart:= p_dt-trunc(p_dt,'DD');
        SELF.week:=    to_char(p_dt,'IW');
        return;
      end;
    end;
    select date_object(sysdate),
           date_object(sysdate).year
    from dual;Regards,
    Sayan M.

  • Fetching month and year from CV of Time dim

    Hi,
    I am working on BPC 7 MS version, SP3. I need to fetch Month and Year values from my Current View (i.e., %TIME_SET%) .... and if the month is AUG and year is Current I then want a logic to run... Is this possible??
    I have written the following code, and only if i hardcode the time (WHEN TIME IS 2009.AUG) the logic seems to work. But I want it to be dynamic
    *XDIM_MEMBERSET ACCOUNT=INC_REC_IN_AD
    *XDIM_MEMBERSET TIME=%YEAR%.AUG,%TIME_SET%
    *XDIM_MEMBERSET CATEGORY=ACTUAL
    *WHEN ACCOUNT
    *IS *
    *WHEN TIME.MONTHNUM
    *IS 8
    *FOR %YEAR%=%TIME_SET%.YEAR
    *FOR %MONTH%=AUG,SEP,OCT,NOV,DEC
    *REC(FACTOR=1/5,TIME="%YEAR%.%MONTH%",ACCOUNT="TEMPSTUDYEDU")
    *NEXT
    *NEXT
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Thanks,
    Prasanth.

    I think your formula is correc the %YEAR% is not a valid, Can you trap that and see what is being passed, you may also try to split the year out of %TIME%
    hope it helps.

  • Elapse days - calculation from month and year

    Duplicate thread ...
    coding  required for converting month into days
    I have Month and year field in my DSO --Year( 2009), Month(4)
    I want below logic to calculate -
    MTD qty % = (qty * elapse days) / no of days in month
    so from the above, I want to know,
    1. How can we get the no of days from the above 2 objects (year and month).
    2. Elapse days are the days that are over from current date to Ist day of that month.
    eg: current date - 04.03.2009 , 1st day of the month - 04.01.2009,
    elapse days = 2. (you need to consider all days in the month, not only working days)
    so my questions is how can we get, # of days n a month from above 2 fields and elapse days based on the above condition.
    also want to know, where can I have the logic in transformations or query level.
    please provide your suggestions.
    Thanks,
    Pra
    Edited by: Arun Varadarajan on Apr 5, 2009 10:44 PM
    Edited by: Arun Varadarajan on Apr 5, 2009 10:45 PM

    Hello,
    I think the sample program below does what you ask: it finds the days in the month (bit of an overkill to use function modules for that) and then computes the QTD.
    Note that the internal string representation of a data variable is always YYYYMMDD, regardless of the "externalized" form (e.g. yyyy/mm/dd or dd.mm.yyyy), so this code will work regardless of your custom date format.
    Regards,
    Mark
    REPORT  zqty_to_date.
    PARAMETERS:
      p_date     TYPE dats,
      p_qty      TYPE i.
    DATA:
      days      TYPE i,
      n_year    TYPE numc4,
      n_month   TYPE numc2,
      n_day     TYPE numc2,
      qtd(6)    TYPE p DECIMALS 1.
    START-OF-SELECTION.
      n_year = p_date+0(4).
      n_month = p_date+4(2).
      n_day = p_date+6(2).
      PERFORM days_in_month USING n_year n_month CHANGING days.
      qtd = ( p_qty * ( n_day - 1 ) ) / days.
      WRITE: / 'Days in month:', days,
             / 'Qty  to date :', qtd.
    *&      Form  days_in_month
    *       text
    FORM days_in_month USING year month CHANGING days.
      DATA: ymod4   TYPE i,
            ymod100 TYPE i,
            ymod400 TYPE i.
      CASE month.
        WHEN 4 OR 6 OR 9 OR 11.
          days = 30.
        WHEN 2.
          ymod4 = year MOD 4.
          ymod100 = year MOD 100.
          ymod400 = year MOD 400.
          IF ( ymod4 = 0 AND ymod100 > 0 ) OR ( ymod100 = 0 AND ymod400 = 0 ).
            days = 29.
          ELSE.
            days = 28.
          ENDIF.
        WHEN OTHERS.
          days = 31.
      ENDCASE.
    ENDFORM.                    "days_in_month

  • Parameter for Last Week, Last Month & Last Year from the current Date

    I have a crystal report that has a StartDate & EndDate parameters from the stored procedure that I am calling. Now i got a new requirement saying that my user wants a drop-down parameter in which they need to be able to select last week (Sunday to Saturday), last month, last year instead of manually selecting start date and end date parameters? Can anyone please explain me how to do this?
    (FYI, I am using Crystal 2008)

    Hi Naveen,
    You'll need to handle the logic in the Stored Proc's where clause.
    If you're using oracle, I have something like this in the Stored Proc's where clause for our reports:
    Where {Date_Field} Between
    Decode('{?Relative Date}',
    'Yesterday', sysdate - 1,
    'Last Week', Tunc(sysdate, 'IW')-7)
    AND
    Decode('{?Relative Date}',
    'Yesterday', sysdate,
    'Last Week', Tunc(sysdate, 'IW'))
    where 'Relative Date' is a prompt in the Stored Proc and 'yesterday'. 'last week' are the 'static values' in the prompt.
    -Abhilash

  • I am attempting to have cells use data from a selective month from the year before so that I can show actual from the prio. years each month.

    I am attempting to have cells use data from a selective month from the year before so that I can show actual from the prio. year each month. I need to create a spreedsheet using the the Acutlas from the year-to-date and from last year-to-date, but need to report each month.

    Hi Tony,
    Answering your question would be easier given a screen shot of the source table and one of what you want the summary table to look like.
    Is the data you want for each month in a single cell o the source table, or does the summary table need to collect February's data (for example) from several cells and do some math with those numbers before presenting them on the summary table?
    Regards,
    Barry

  • Can i get month, quarterly, half yearly, yearly wise sales report basing on

    hi,
    sap gurus,
    good evening to all,
    how can i get month, quarterly, half yearly, yearly wise sales report basing on division and material.
    is there any std transaction code for that.
    customization is requried for that.
    regards,
    balaji.t
    09990019711

    Standard SAP SD Reports:=
    Statistic Group:
    Purpose u2013 To capture data for Standard Reports, we require to activate Statistic Group as under:
    --> Item category (Configuration)
    --> Sales document type (Configuration)
    --> Customer (Maintain in Master data)
    --> Material (Maintain in Master data)
    When you generate statistics in the logistics information system, the system uses the combination of specified statistics groups to determine the appropriate update sequence. The update sequence in turn determines for exactly which fields the statistics are generated.
    Configuration:
    IMG --> Logistics Information System (LIS) --> Logistics Data Warehouse --> Updating --> Updating Control --> Settings: Sales --> Statistics Groups -->
    1. Maintain Statistics Groups for Customers
    2. Maintain Statistics Groups for Material
    3. Maintain Statistics Groups for Sales Documents
    4. Assign Statistics Groups for Each Sales Document Type
    5. Assign Statistics Groups for each Sales Document Item Type .....
    All Standard Reports which are available are as under:
    SAP Easy Access: Information Systems -> Logistics -> Sales and distribution ->
    1. Customer -> Incoming orders / Returns / Sales / Credit memos / Sales activities / Customer master / Conditions / Credit Master Sheet
    2. Material -> Incoming orders / Returns / Sales / Credit memos / Material master / ...
    3. Sales organization -> Sales organization / Sales office / Sales employee
    4. Shipping point -> Deliveries / Returns
    5. SD documents -> Orders / Deliveries / Billing documents ...
    & so on.
    Regards,
    Rajesh banka

  • I am a US resident but spend several months each year at my house in England. Is it possible for me to download UK iPad apps from the iTunes Store? Right now they seem to be restricted. Can I set up an alternate iTunes account using a UK credit card?

    I am a US resident but spend several months each year at my house in England. Is it possible for me to download UK iPad apps from the iTunes Store? Right now they seem to be restricted. Can I set up an alternate iTunes account using a UK credit card?

    When you go to Starbucks, you'll need to first go to Settings on your iPad and choose Network. You'll see ATTWIFI as one of the available networks. When you click on that to select it, you should be immediately sent to AT&T's sign in page. You just need to check the box that says you agree to their terms and conditions and then hit the Connect button and you'll be online. One warning, however. If your Starbucks is anything like those in Manhattan, be prepared for really slow wifi. It can be a real pain waiting for pages to load sometimes.

  • SQL select Statement -first day and last day of the month - 1 year from now

    Hi,
    I need to write a SQL to get the dates in between first day and last day of the month one year from now.
    SELECT last_day(add_months(sysdate,12)) as lastday from dual
    What could be the Query to get the first day of the month one year from now..
    ie ..Sysdate - 3-DEC-2009
    Result - 1-DEC-2010
    thank you

    Hi,
    You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
    SELECT  TRUNC ( ADD_MONTHS ( SYSDATE
                               , 12
                  , 'MONTH'
                  )     AS first_of_month
    FROM    dual
    ;The DATE returned will be in the same month, year, quearter, ... as the first argument.
    \We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
    At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
    For example, to find all appointment_dates in the current month next year:
    SELECT  *
    FROM    appointments
    WHERE   appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
    AND     appointment_date <  TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
    the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
    the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future.

  • Getting Day, month and year from Date object

    hello everybody,
    Date mydate = Resultset.getDate(indexField);
    Now i would like to get day, month and year from mydate.
    In another words, i'm looking for something equivalent to
    mydate.getDay() as this method is deprecated.
    Can somebody help me out please?
    Thank you in advance,

    swvc2000,
    Here is a sample class that demonstrates two ways in which to do this.import java.util.*;
    import java.text.*;
    public class DateSplitter {
       public static void main(String args[]) {
          /* even though your date is from a result set,
             pretend the following date is your date that
             you are using. The try catch block is used
             because I hand-crafted my date using
             SimpleDateFormat.  Substitute your date.*/
          Date yourDate = null;
          try {
             SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
             yourDate = formatter.parse("05/06/2000");
          } catch (ParseException e) { }
          //the following gets the current date
          Calendar c = Calendar.getInstance();
          //use the calendar object to set it to your date
          c.setTime(yourDate);
          //note months start at zero
          int month = c.get(Calendar.MONTH);
          int year = c.get(Calendar.YEAR);
          int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
          System.out.println("Calendar Month: "+month);
          System.out.println("Calendar Day: "+dayOfMonth);
          System.out.println("Calendar Year: "+year);
          System.out.println();
          /* Simple date format can also be used to strip them
             out of your date object.  When you use it, notice that
             months start at 1.  Also, it returns string values.  If
             you need integer values, you will have to use
             Integer.parseInt() as I did below.  If you are
             only concerned about the string values, just remove
             the Integer.parseInt part. */
          DateFormat formatter = new SimpleDateFormat("M");
          month = Integer.parseInt(formatter.format(yourDate));
          System.out.println("SDF Month: "+ month);
          formatter = new SimpleDateFormat("d");
          dayOfMonth = Integer.parseInt(formatter.format(yourDate));
          System.out.println("SDF Day: "+ dayOfMonth);
          formatter = new SimpleDateFormat("yyyy");
          year = Integer.parseInt(formatter.format(yourDate));
          System.out.println("SDF Year: "+ year);
       }//end main
    }//end DateSplitter classtajenkins

  • Get month and year from date type

    Hi all,
    I need to get the month and year from the date type.
    For example select to_date('2011-01-17', 'yyyy-mm-dd') from dual;Result needed:
    01-2011Any ideas?
    thanks in advance,
    Bahchevanov.

    Hello Bahchevanov,
    if you need the date to compute something, then you can
    TRUNC(SYSDATE,'mm')This will give you a date with the days removed -> 01.01.2011
    Regards
    Marcus

  • Max month and year from table

    Hi,
    I have requirement to get max month and year from a table.
    DESC WHR_REPORT
    REPORTMONTH   NUMBER(2)
    REPORTYEAR    NUMBER(4)
    Sample data in table
    reportmonth    reportyear
    01              2009
    02              2009
    03              2009
    04              2009
    09              2009
    12              2009
    01              2010
    02              2010how do i get the max date which means 022010 from the table?
    thanks
    sandy

    Give this a shot:
    SQL> WITH whr_report AS
      2  (
      3         SELECT 01 AS reportmonth, 2009 AS reportyear FROM DUAL UNION ALL
      4         SELECT 02 AS reportmonth, 2009 AS reportyear FROM DUAL UNION ALL
      5         SELECT 03 AS reportmonth, 2009 AS reportyear FROM DUAL UNION ALL
      6         SELECT 04 AS reportmonth, 2009 AS reportyear FROM DUAL UNION ALL
      7         SELECT 09 AS reportmonth, 2009 AS reportyear FROM DUAL UNION ALL
      8         SELECT 12 AS reportmonth, 2009 AS reportyear FROM DUAL UNION ALL
      9         SELECT 01 AS reportmonth, 2010 AS reportyear FROM DUAL UNION ALL
    10         SELECT 02 AS reportmonth, 2010 AS reportyear FROM DUAL
    11  )
    12  -- END SAMPLE DATA
    13  SELECT  MAX
    14          (
    15            TO_DATE
    16            (
    17              LPAD
    18              ( reportmonth
    19              , 2
    20              , '0'
    21              ) || reportyear
    22            , 'MMYYYY'
    23            )
    24          ) AS MAX_DT
    25  FROM    whr_report
    26  /
    MAX_DT
    02/01/2010 00:00:00This is a case where you should use the correct data types to store data. These two column should be ONE column with a data type of DATE.

Maybe you are looking for

  • Issue in applying SSL selectively to Login JSP Page--Session getting lost.

    Hi, I am facing some issues with SSL configuration on my web site running on tomcat 5.5. I am using jdk 1.5 and form based authentication with JAAS framework. The SSL configuration is working perfectly when applied to complete web site, but starts gi

  • Cannot edit Infoset in BI (7.0)

    For some reason, I am just not able to see the add infoprovider icon when I am in edit mode of an infoset in BI (7.0 version). Am I missing something here? Thanks!

  • Get current version of LCA

    Hi, I have a process which at the moment requires me to state the version of the LCA file (currently being hardcoded) this process is currently in. We regularly increment/change the LCA version number as when required and hence when we do so, we woul

  • BFD no group info for section

    Hi, I am using Solaris 8 with CC version : CC: Sun C++ 5.8 2005/10/13 When I am trying to build a library I get following messages. The library gets build fine, but I see lots of these messages, can you please help me find the reason for this and fix

  • How in the hell do I completely uninstall the creative cloud from my computer?

    I have deleted the applications and the Updater is still on my menu bar. (Mac) I read that you can go to preferences and manage from there but now when I click "Open Updater" it says error...probably because I deleted the files. I just want this off