Calculate subtraction by a specific quarter of year

I have some records after SQL generating:
YEARS MONTHS SUMMONTH SUMQUARTER QTR
2009 Jan      363639     855922 1  
2009 Feb      128305     855922 1  
2009 Mar      363978     855922 1  
2009 Apr      376633    1058871 2  
2009 May      299140    1058871 2  
2009 Jun      383098    1058871 2  
2009 Jul      435000    1063577 3  
2009 Aug      266227    1063577 3  
2009 Sep      362350    1063577 3  
2009 Oct      449366    1017906 4  
2009 Nov      280943    1017906 4  
2009 Dec      287597    1017906 4  
2010 Jan      418277     661083 1  
2010 Feb      129895     661083 1  
2010 Mar      112911     661083 1  
2010 Apr      163593     685625 2  
2010 May      228505     685625 2  
2010 Jun      293527     685625 2  
2010 Jul      451608    1044364 3  
2010 Aug      356683    1044364 3  
2010 Sep      236073    1044364 3  
2010 Oct      247365     798925 4  
2010 Nov      414100     798925 4  
2010 Dec      137460     798925 4  
24 rows selected The SUMQUARTER column sum up each quarter of a year... The qtr specify it belongs to which quarter.
The problem is how to have a subtraction of sumquarter between 2 different years to get the specific query result?
The difference is not the: max value-min value. It is the user-defined value that he want to input...
Let say... For example, the user want to see the substraction(sumquarter) between 2009 qtr=2 and 2010 qtr=2, user may change the parameter(years,qtr) of sql to view the record.
This mean the result should be: (1058871 - 685625)
Here is the SQL that I am currently using:
select years,months,summonth,sumquarter,qtr
from(
        select years,months,summonth,sumhour,hours,to_char(ym, 'Q') qtr,
                sum(sumhour) over(partition by years || to_char(ym, 'Q') order by years || to_char(ym, 'Q')) sumquarter,ym,
                count(days) over(partition by years,months,hours) days_month
        from(
                select   years, months, days, hours, mins, sumHour,
                         SUM (sumHour) OVER (PARTITION BY years,months,days) sumDay,
                         SUM (sumHour) OVER (PARTITION BY years,months) sumMonth,
                         SUM (sumHour) OVER (PARTITION BY years) sumyear,
                         to_date(years || months, 'YYYYMon', 'NLS_DATE_LANGUAGE=American') ym
                from  (
                        SELECT x.years, x.months, x.days, x.hours, x.mins, sum(x.value) as sumHour
                        FROM xmltest,
                             XMLTABLE ('$d/cdata/name' passing doc as "d"
                                        COLUMNS
                                          years integer path 'year',
                                          months varchar(3) path 'month',
                                          days varchar(2) path 'day',
                                          hours varchar(2) path 'hour',
                                          mins varchar(2) path 'minute',
                                          value float path 'value'
                                       ) as X
                        group by x.years, x.months, x.days, x.hours, x.mins
                        order by x.years, x.months, x.days
  group by years,months,summonth,sumquarter,qtr,ym
  order by ymThe sql pattern maybe something like this:...??
select ((select sumquarter from table where years=2009 and qtr=2) - (select sumquarter from table where years=2010 and qtr=2)) from tableActually, it doesn't work...
The result maybe look in this view:
SUBTRACT
373246Thanks everyone helps!!:)
Edited by: 920575 on 2012/3/27 上午 1:50

ok...I am so sorry to make you confused...
Here is my sql which combined with yours:
with tbl as (
select years,months,summonth,sumquarter,qtr
from(
        select years,months,summonth,sumhour,hours,to_char(ym, 'Q') qtr,
                sum(sumhour) over(partition by years || to_char(ym, 'Q') order by years || to_char(ym, 'Q')) sumquarter,ym,
                count(days) over(partition by years,months,hours) days_month
        from(
                select   years, months, days, hours, mins, sumHour,
                         SUM (sumHour) OVER (PARTITION BY years,months,days) sumDay,
                         SUM (sumHour) OVER (PARTITION BY years,months) sumMonth,
                         SUM (sumHour) OVER (PARTITION BY years) sumyear,
                         to_date(years || months, 'YYYYMon', 'NLS_DATE_LANGUAGE=American') ym
                from  (
                        SELECT x.years, x.months, x.days, x.hours, x.mins, sum(x.value) as sumHour
                        FROM xmltest,
                             XMLTABLE ('$d/cdata/name' passing doc as "d"
                                        COLUMNS
                                          years integer path 'year',
                                          months varchar(3) path 'month',
                                          days varchar(2) path 'day',
                                          hours varchar(2) path 'hour',
                                          mins varchar(2) path 'minute',
                                          value float path 'value'
                                       ) as X
                        group by x.years, x.months, x.days, x.hours, x.mins
                        order by x.years, x.months, x.days
  group by years,months,summonth,sumquarter,qtr,ym
  order by ym
tagg as (
select years, qtr, sumquarter
   from tbl
   group by years, qtr, sumquarter
       select ta.years Ya, ta.qtr Qa, tb.years Yb, tb.qtr Qb, abs(ta.sumquarter - tb.sumquarter) diffAB
         from tagg ta
         join tagg tb
         on (1=1)
       where ta.years=2010 and ta.qtr=1
           and tb.years=2009 and tb.qtr=1;It will display as "No data to read from socket".........
I can provided the insert query if you would like to have one. I can't paste at here because it is so large...

Similar Messages

  • Find the difference between two dates for the specific month and year

    Hi,
    I have two dates, start date is 30/12/2012 and end date is 04/01/2013. Using datediff I found the difference of days between two dates. But I find the no of days in January 2013. ie output is 4 instead of 6. I input month and year to find the no of days
    for that date. In this case I input Jan 2013. How can I sql this ?

    I don't understand how most of the answers provided here not analytically solving the problem with many cases possible.
    First let me understand you:
    You have 2 dates range and you want to calculate day range for specific month and year between the original date range.
    declare @for_month int = 1 --January
    declare @for_year int = 2013
    declare @StartDate date = '2012-12-20'
    declare @EndDate date = '2013-01-04'
    SELECT
    CASE
    WHEN (DATEPART(MONTH, @StartDate) = @for_month and DATEPART(MONTH, @EndDate) = @for_month) and ((DATEPART(YEAR, @StartDate) = @for_year or DATEPART(YEAR, @EndDate) = @for_year)) THEN
    DATEDIFF(DAY, @StartDate,@EndDate)
    WHEN (@StartDate < cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (@EndDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, DATEADD(MONTH, DATEDIFF(MONTH, -1, @EndDate)-1, 0),@EndDate)
    WHEN (@EndDate > cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) and (@StartDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, @StartDate,DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, @StartDate) + 1, 0))) + 1
    WHEN ((DATEDIFF(DAY, @StartDate, cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) >= 0) and (DATEDIFF(DAY, cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date), @EndDate) >= 0)) THEN
    DATEDIFF(DAY, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime), DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime)) + 1, 0))) + 1
    ELSE
    0
    END as [DD]
    I don't know how you calculate day range between 01/01/2013 and 04/01/2013
    is 4, it is actually is 3 but if that is the case, you can add 1 from the condition.

  • Fiscal QTD and Fiscal QTD - Same Quarter, Prior Year

    Hello,
    I am having some issues creating the DAX formulas in my Tabular model for Fiscal QTD.  Our fiscal period ends on Feb 28th (or 29th).  I managed to get the Fiscal QTD working by using the following formula:
    Transaction $ Fiscal QTD:=CALCULATE (
        [Transaction $ Current Day],
        FILTER (
            ALL ( 'Dates' ),
            'Dates'[Fiscal Year] = VALUES(Dates[Fiscal Year])
                && 'Dates'[Fiscal Quarter] = VALUES ( 'Dates'[Fiscal Quarter] )
                && 'Dates'[Calendar Date] <= MAX ( 'Dates'[Calendar Date] )
    However when I try to use this formula for Fiscal QTD, Same Quarter-Prior Year, I get an incorrect total:
    Transaction $ Fiscal QTD Prior Year:=CALCULATE (
        [Transaction $ Current Day],
       FILTER (
            ALL ( 'Dates' ),
            'Dates'[Fiscal Year] = VALUES(Dates[Fiscal Year]) - 1
                && 'Dates'[Fiscal Quarter] = VALUES ( 'Dates'[Fiscal Quarter] )
                && 'Dates'[Calendar Date] <= MAX ( 'Dates'[Calendar Date])
    Values in the Fiscal Quarter and Fiscal Year columns of the date dimension are integers.
    Does anyone have any insight into Fiscal QTD DAX formulas?
    Cheers,
    Stan

    Does anyone have a suggestion for Stan?
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Change date format to Quarter and year. Example: Q1 2009

    Hi all,
    Anyone who knows how to display the date as quarter and year instead of day, month and year?
    Example: Instead of displaying the Start or End date as 01.01.2009 we would like to display it as Q1 2009.
    We are using CRM 2007.
    Thanks in advance.
    //Anders

    Hi,
    Try CRM_PPM_TRANS_DATE_TO_QUARTER.
    Regards,
    Shahina

  • Week, Month,Quarter and year

    I have a specific query. I my dashboard i have prompts for Year, quarter, month and week.
    Based on the week selection i get some sales data. And i use AGO function to get previous week's data.
    Now i am in a fix with my other requirement. I need the monthly data and quarterly data, for that particular week.
    Example:-
    Week 19th Nov 2011. I am ale to get the data with existing report.
    Month NOV:- If i use todate fundtion then i will get November's data untill Week of 19th November. BUT I WANT FULL NOVEMBER'S DATA.
    Quarter 2011-4:- If i use todate fundtion with quarter parameter then i will get fourth quarter's data until Week of 19th November. BUT I WANT FULL FOURTH QUARTER'S DATA.
    How do i achieve this.

    When i try this in a new column formula, it shows me the correct date.
    TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH("MIS Dates"."MIS Date") * -1 , TIMESTAMPADD(SQL_TSI_MONTH, 1, "MIS Dates"."MIS Date"))
    But when i use the same with todate function, then it gives syntax error. I am clueless.
    Todate((("Vendor Performance"."Landed CostQty AC") /"Vendor Performance"."PO Qty"), TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH("MIS Dates"."MIS Date") * -1 , TIMESTAMPADD(SQL_TSI_MONTH, 1, "MIS Dates"."MIS Date")))
    Please help.

  • Filter value for specific quarter

    I have a report that shows value for last two years by quarter. The requirment I got ask for comparing each quarter value with last year Q4 value.
    It is like:
    2011Q1
    2011 Q 2
    2011 Q 3
    2011 Q4
    2012 Q1
    2012 Q2
    2012 Q3
    2012 Q4
    2011 Q1/2010 Q4
    2011 Q2/2010 Q4
    2011 Q3/2010Q4
    2011Q4/2010Q4
    2012 Q1/2011 Q4
    2012 Q2/2011 Q4
    2012 Q3/2011 Q4
    2012 Q4/2011 Q4
    How shoud I write the formular to achive this? Thank you for your input.

    create a column that store previous quarter result and then use the formula to create another column to store the comparision.
    The formula would be case when start_date>= @year_start and end_date <= @year_end then table.measure/table.measure_previous_quarter end
    Please mark if helpful.
    Regards,
    Akansh Agarwal

  • Calculate the number of days in a year excluding Saturday and Sunday

    Hi All,
    I need to get the number of days in a year excluding Saturday and Sunday for HR module and then subtract the public holidays.
    Can some let me know how this needs to be done while loading data from one infocube to another.
    Is there any Function module for the same so that i can write any start routines.
    And also is there any table available for Tcode-SCAL with which i can write any start routines.
    Kindly help me as soon as possible.
    Regards,
    Kumar

    Hi Harish
    Refer to the screenshot for Import and Export parameters
    Code
    FUNCTION ZBI_FM_GET_HOLIDAYS .
    *"*"Local Interface:
    *"  IMPORTING
    *"    VALUE(DATE_FROM) TYPE  SCAL-DATE DEFAULT SY-DATUM
    *"    VALUE(DATE_TO) TYPE  SCAL-DATE DEFAULT SY-DATUM
    *"    VALUE(FACT_CAL) TYPE  SCAL-FCALID DEFAULT SPACE
    *"    VALUE(ONLYFACT_DAYS) TYPE  CHAR1 OPTIONAL
    *"  EXPORTING
    *"    REFERENCE(HOLIDAYS) TYPE  I
    *"  TABLES
    *"      DAY_ATTRIBUTES STRUCTURE  CASDAYATTR
    *"  EXCEPTIONS
    *"      FACTORY_CALENDAR_NOT_FOUND
    *"      HOLIDAY_CALENDAR_NOT_FOUND
    *"      DATE_HAS_INVALID_FORMAT
    *"      DATE_INCONSISTENCY
    DATA: LT_DAY_ATTRIBUTES TYPE TABLE OF  CASDAYATTR WITH HEADER LINE.
    DATA: LV_LINES TYPE SY-SUBRC.
    DATA: DATE1 LIKE DATE_FROM,
    DATE2 LIKE DATE_TO.
    *if from date is gt to date then interchange the dates and multiply the result with -1.
    IF DATE_FROM GT DATE_TO.
    DATE2 = DATE_FROM.
    DATE1 = DATE_TO.
    ELSE.
    DATE1 = DATE_FROM.
    DATE2 = DATE_TO.
    ENDIF.
    CALL FUNCTION 'DAY_ATTRIBUTES_GET'
    EXPORTING
    FACTORY_CALENDAR                = FACT_CAL
    *  HOLIDAY_CALENDAR                = ' '
    DATE_FROM                        = DATE1
    DATE_TO                          = DATE2
    LANGUAGE                        = SY-LANGU
    * IMPORTING
    *  YEAR_OF_VALID_FROM              =
    *  YEAR_OF_VALID_TO                =
    *  RETURNCODE                      =
    TABLES
    DAY_ATTRIBUTES                  = LT_DAY_ATTRIBUTES
    EXCEPTIONS
    FACTORY_CALENDAR_NOT_FOUND      = 1
    HOLIDAY_CALENDAR_NOT_FOUND      = 2
    DATE_HAS_INVALID_FORMAT          = 3
    DATE_INCONSISTENCY              = 4
    OTHERS                          = 5 .
    IF SY-SUBRC = 0.
    IF ONLYFACT_DAYS = 'X'.
    DELETE LT_DAY_ATTRIBUTES WHERE FREEDAY EQ SPACE.
    ELSE.
    DELETE LT_DAY_ATTRIBUTES WHERE WEEKDAY LT 6.
    ENDIF.
    DESCRIBE TABLE LT_DAY_ATTRIBUTES LINES LV_LINES.
    HOLIDAYS =  LV_LINES.
    *    IF DATE_FROM GT DATE_TO.
    *      HOLIDAYS = HOLIDAYS * -1.
    *    ENDIF.
    ELSEIF SY-SUBRC = 1.
    RAISE FACTORY_CALENDAR_NOT_FOUND.
    ELSEIF SY-SUBRC = 2.
    RAISE HOLIDAY_CALENDAR_NOT_FOUND.
    ELSEIF SY-SUBRC = 3.
    RAISE DATE_HAS_INVALID_FORMAT.
    ELSEIF SY-SUBRC = 4.
    RAISE DATE_INCONSISTENCY.
    ENDIF.
    ENDFUNCTION.

  • Do you know of any date specific transactions for year end processes?

    We are using SAP ECC6 SD, MM, FI, CO with COPA. Our number ranges are not year specific. We have control of currency conversion rates and they are allowed for.
    I have gone through all the end of year transactions listed in our manual and cannot see any that must be carried out on the last day and cannot be done retrospectively. However, we have previously had problems with this in other systems so, just to be sure, does anyone know of any SAP transaction for end of year processes that must be carried out on the last day, and only the last day, of the period?
    Thanks in advance
    David

    Hi,
    Though the period end activities are not date specific, there surely exists an order with which it should berun.
    Regards,
    Sridevi

  • Calculate text with for specific font

    Hi,
    is there some support to calculate the width of a text with a specific font? E. g. if the font is equi-distant or not or different size, it has a different width.
    Regards
    Oliver

    You can add a listener and then (I assume) make changes if the text does not fit:
    txt.widthProperty().addListener(new ChangeListener() {          
                 @Override public void changed(ObservableValue o,Object oldVal, Object newVal){
                      if ( newVal instanceof Double){
                           double xw = (Double) newVal;                       
               });

  • Need to calculate interest paid/earned for the coming year ...

    All,
    Working up the 2010 budget, and decided to give Numbers a whirl vs. continuing with M$ Excel for another year. One of the things I do is make some kind of educated estimate on how much my interest I will pay on each of my loans in the following year.
    Example - auto loan:
    Balance: $10,000
    Interest rate: 7%
    Payment: $200/month
    You get the idea. Does Numbers have a formula that will calc the effective interest I would have paid by December 2010, recalculating the new principal and interest each month as the balance goes down, etc? I looked at IPMT, but some of the variables don't seem to make sense to me.
    Appreciate the help in advance.
    Bones

    Ok, that works for some things. (Thanks again).
    If you have a fixed-term loan (auto, home, etc.) then CUMIPMT seems to work great. But in the case of revolving credit lines, credit cards, where there is no fixed term the formula breaks down.
    For example:
    CreditCardX
    - APR: 10%
    - Balance: $5,000
    - Projected payment/month: $150
    CreditCardY
    - APR: 12%
    - Balance: $4,000
    - Projected payment/month: $125
    In the coming 12 months, I want to play with the numbers to see how much interest I will pay on X versus Y over the coming year ... up the payment on X and see how that changes things versus upping the payment on Y ... you get the idea.
    I guess I can just create a manual formula (?)
    Still appreciate any help as I am figuring out Numbers.
    Bones

  • Accumulated values from rpsco up to specific period and year

    I am develping report with parameters: period and year.
    Then my programs need to accumulate values in table rpsco from the period 01 year 1800 and up to period and year in my selection.
    Any suggestions?

    Hi Prasad,
    This would be happening if you have put the user entry variable in the global filter of your query.
    As a result the complete data set is restrcted to get the data only for one month.
    Please use the variable for user entry month in a selection and not globally.
    -Vikram

  • How to calculate power in specific frequency band

    Hi Everyone. I have been trolling on here for months but this is my first post so I hope I am putting this in the correct place.
    What I am trying to do is simple in theory but I have tried over and over and am having no luck in getting this to work. I wish to calculate the power in specific frequency bands for heart rate variability analysis.
    Referring to the article "Using LabVIEW for Heart Rate Variability Analysis"  http://zone.ni.com/devzone/cda/epd/p/id/5832 I am aware of the steps I need to follow.
    I have plotted the RR intervals and resampled these with cubic spline interpolation to give a nice time dependent series. I then wire this to a PSD VI and this is where I am out of my depth.
    I know from the above article that I am looking for power in these frequency bands
    VLF  
    ms2
    Power from 0–0.04 Hz.
    LF  
    ms2
    Power from 0.04–0.15 Hz.
    HF
    ms2
    Power from 0.15–0.4 Hz.
    The NI Biomedical Startup kit can do these, however I am unable to look into the source code as I do not have some required plugins in my installation. I have LabVIEW 8.6 full development system.
    As this is not my area there is a steep learning curve and I have read many forum posts and pages but am still unsure of what I need to do here.
    It is my understanding that the frequency resolution is simply the sample rate/number of samples. So if I require a resolution of 0.01Hz then theoretically 100Hz sample rate and 10,000samples would give me this.Furthermore I gather that the size of the output array from the PSD VI is equal to the # of data points (This i have just noticed from trial and error so I may be wrong).
    Therefore if I am using the above values then is it correct that PSD would return an array and all I need to do is simply sum the contents of those array elements to get the power?
    For example if frequency resolution is 0.01 , then to get power from 0-0.04Hz I must simply add the first 4 elements in the PSD output array?
    I have made a test VI to show what I am talking about and attached it to this post.
    Some feedback on the required approach would be a lifesaver here. I have purchased a couple of books and read through pages of forum posts but am still having trouble with this.
    Many thanks!
    Attachments:
    labviewhelp.jpg ‏53 KB

    Sorry about that, I didn't realize you wanted to run the code too The VI was doing a bunch of other stuff so I have tried to clean that out and just leave the relevant bit. As mentioned above, the case block executes when a peak is detected in the data and appends this value to an array.
    I am using the technique of resampling the data because this is what was mentioned in this http://zone.ni.com/devzone/cda/epd/p/id/5832 and also in another reference that I have been following titled "Heart Rate Variability Standards of Measurement, Physiological Interpretation, and Clinical Use" http://circ.ahajournals.org/cgi/content/full/93/5/1043 which states
    "The spectrum of the HRV signal is generally calculated eitherfrom the RR interval tachogram (RR durations versus number ofprogressive beats; see Fig 5a,b) or by interpolating the DES,thus obtaining a continuous signal as a function of time, orby calculating the spectrum of the counts–unitary pulsesas a function of time corresponding to each recognized QRS complex.35Such a choice may have implications on the morphology, themeasurement units of the spectra, and the measurement of therelevant spectral parameters. To standardize the methods used,the use of RR interval tachogram with the parametric method,or the use of the regularly sampled interpolation of DES withthe nonparametric method may be suggested; nevertheless, regularlysampled interpolation of DES is also suitable for parametricmethods. The sampling frequency of interpolation of DES mustbe sufficiently high that the Nyquist frequency of the spectrumis not within the frequency range of interest."
    Attachments:
    Exp-PulseOximeter.vi ‏205 KB

  • How to define a dynamic column to count the quarter of each year?

    Lets see the result that now displayed:
    YEARS MONTHS SUMMONTH SUMYEAR SUMQUARTER
    2009 Jan      127994 1766166     449652
    2009 Feb      168106 1766166     449652
    2009 Mar      153552 1766166     449652
    2009 Apr      160329 1766166     438913
    2009 May      137605 1766166     438913
    2009 Jun      140979 1766166     438913
    2009 Jul      148606 1766166     435283
    2009 Aug      150390 1766166     435283
    2009 Sep      136287 1766166     435283
    2009 Oct      149529 1766166     442318
    2009 Nov      153268 1766166     442318
    2009 Dec      139521 1766166     442318
    2010 Jan      124670 1721212     407181
    2010 Feb      139278 1721212     407181
    2010 Mar      143233 1721212     407181
    2010 Apr      149518 1721212     444112
    2010 May      152292 1721212     444112
    2010 Jun      142302 1721212     444112
    2010 Jul      149125 1721212     412855
    2010 Aug      130328 1721212     412855
    2010 Sep      133402 1721212     412855
    2010 Oct      157754 1721212     457064
    2010 Nov      137078 1721212     457064
    2010 Dec      162232 1721212     457064
    The problem is about how to dynamic a new column called "Q_count" to count each displayed row belong to which quarter of year??
    In addition, it will repeat again from next year.
    For example:
    *2009 Jan-Mar will display "q1", Apr-Jun will display "q2".....and for 2010 Jan-Mar, it will display "q1" again and so on.*
    Here is my sql that I am using:
    select years,months,summonth,sumyear,sumquarter
    from(
    select years,months,summonth,sumyear,
            sum(sumhour) over(partition by years || to_char(ym, 'Q') order by years || to_char(ym, 'Q')) sumquarter,ym
    from(
    select years, months, days, hours, mins, sumHour, SUM (sumHour) OVER (PARTITION BY years,months,days) sumDay, SUM (sumHour) OVER (PARTITION BY years,months) sumMonth, SUM (sumHour) OVER (PARTITION BY years) sumyear,
    to_date(years || months, 'YYYYMon', 'NLS_DATE_LANGUAGE=American') ym
    from (SELECT x.years, x.months, x.days, x.hours, x.mins, sum(x.value) as sumHour
    FROM xmltest,
    XMLTABLE ('$d/cdata/name' passing xmldoc as "d"
       COLUMNS
      years integer path 'year',
      months varchar(3) path 'month',
      days varchar(2) path 'day',
      hours varchar(2) path 'hour',
      mins varchar(2) path 'minute',
      value float path 'value'
      ) as X
      group by x.years, x.months, x.days, x.hours, x.mins
      order by x.years, x.months, x.days
      group by years,months,summonth,sumyear,sumquarter,ym
      order by ymThanks everyone helps me!!!

    If my understanding is correct..
    select years,months,summonth,sumyear,sumquarter,qtr
    from(
            select years,months,summonth,sumyear,to_char(ym, 'Q') qtr,
                    sum(sumhour) over(partition by years || to_char(ym, 'Q') order by years || to_char(ym, 'Q')) sumquarter,ym
            from(
                    select   years, months, days, hours, mins, sumHour,
                             SUM (sumHour) OVER (PARTITION BY years,months,days) sumDay,
                             SUM (sumHour) OVER (PARTITION BY years,months) sumMonth,
                             SUM (sumHour) OVER (PARTITION BY years) sumyear,
                             to_date(years || months, 'YYYYMon', 'NLS_DATE_LANGUAGE=American') ym
                    from  (
                            SELECT x.years, x.months, x.days, x.hours, x.mins, sum(x.value) as sumHour
                            FROM xmltest,
                                 XMLTABLE ('$d/cdata/name' passing xmldoc as "d"
                                            COLUMNS
                                              years integer path 'year',
                                              months varchar(3) path 'month',
                                              days varchar(2) path 'day',
                                              hours varchar(2) path 'hour',
                                              mins varchar(2) path 'minute',
                                              value float path 'value'
                                           ) as X
                            group by x.years, x.months, x.days, x.hours, x.mins
                            order by x.years, x.months, x.days
    order by ymEdited by: jeneesh on Mar 26, 2012 5:49 PM
    Removed unnecessary GROUP BY

  • Date Picker - show specific month of perticaular year

    Hi Experts,
    I am using sam.m.DatePicker control. By default date picker show current month-year when user open date picker. I want to show specific month of specific year when date picker is open.
    for eg: In my app, if student appearing for next year exam(say 2016) then when he click on date picker it should show April of 2016 instead of april of 2015. I don't want to set date by default. Student should select that date manually.
    Is it possible to show specific month and year for date picker when it open.
    Thanks in advanced.

    Hi,
    you can also give a default date of the first date of that month.
    Why you are not using that?
    var datePicker = new sap.m.DatePicker({
                                            valueFormat: "yyyy-MM-dd",
                                            displayFormat: "long",
                                                   value: "2014-03-26"
    Regards
    Dhananjay

  • Yearly once inspection for specific characteristic with out inspec. lot

    Hi Experts,
                        My client want some specific characteristic inspection yearly once with out inspection lot.
    help me how to map this scenario
    Regards,
    Sbabu
    Edited by: sbabu babu on Apr 22, 2010 12:27 PM

    I dont think any standard solution for this,
    few suggestions are
    Go for a manual lot, client can track manual lot generation based on a report. report can be ABAP deveoped based on the client requirements. So every day client can run report and know which all materials are to be inspected on that day. I feel this as best.
    DMR may have an issue as unnecessarily lot will get generated throughout the year in system. Its OK, we can do auto UD and all, but think do we really need these data go into system for rest 364 days for that one day inspection. If you ask me, I will say no to it.
    Calibration lots can be generated only for equipments. Its only fixed time based inspection lot. But here material need to be maintained as equipment. i dont think, this is acceptable. Try first one which worked out well for me. Jus a report for tracking.
    Thanks
    Vineeth Varghese

Maybe you are looking for