how every 3 months a year and the dynamics of group a new column?

I have a sql that allows to display the folders below.
YEARS MONTHS SUMMONTH SUMYEAR
----- ------ -------- -------
 2009 Apr      130288 1720164 
 2009 Aug      138776 1720164 
 2009 Dec      140294 1720164 
 2009 Feb      136422 1720164 
 2009 Jan      148253 1720164 
 2009 Jul      149842 1720164 
 2009 Jun      122805 1720164 
 2009 Mar      145872 1720164 
 2009 May      151193 1720164 
 2009 Nov      133487 1720164 
 2009 Oct      169443 1720164 
 2009 Sep      153489 1720164 
 2010 Apr      142255 1719457 
 2010 Aug      135894 1719457 
 2010 Dec      171203 1719457 
 2010 Feb      137011 1719457 
 2010 Jan      145493 1719457 
 2010 Jul      137474 1719457 
 2010 Jun      154411 1719457 
 2010 Mar      133062 1719457 
 2010 May      146887 1719457 
 2010 Nov      139869 1719457 
 2010 Oct      127191 1719457 
 2010 Sep      148707 1719457 

 24 rows selected 
The SQL code that I use:
select years, months, summonth, sumyear
from(
select years, months, SUM (sumHour) OVER (PARTITION BY years,months) sumMonth, SUM (sumHour) OVER (PARTITION BY years) sumyear
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
  order by years
and now the problem of problems can group the sum of 3 months of recording as a quarter of the year in a dynamic column?

The display should be seydou this:
YEARS MONTHS SUMMONTH SUMQUARTER SUMYEAR
----- ------ -------- ---------- -------
 2009 Feb      136422     430547 1720164 
 2009 Jan      148253     430547 1720164 
 2009 Mar      145872     430547 1720164 
 2009 Apr      130288     404286 1720164 
 2009 Jun      122805     404286 1720164 
 2009 May      151193     404286 1720164 
 2009 Aug      138776     442107 1720164 
 2009 Jul      149842     442107 1720164 
 2009 Sep      153489     442107 1720164 
 2009 Dec      140294     443224 1720164 
 2009 Nov      133487     443224 1720164 
 2009 Oct      169443     443224 1720164 
 2010 Feb      137011     415566 1719457 
 2010 Jan      145493     415566 1719457 
 2010 Mar      133062     415566 1719457 
 2010 Apr      142255     443553 1719457 
 2010 Jun      154411     443553 1719457 
 2010 May      146887     443553 1719457 
 2010 Aug      135894     422075 1719457 
 2010 Jul      137474     422075 1719457 
 2010 Sep      148707     422075 1719457 
 2010 Dec      171203     438263 1719457 
 2010 Nov      139869     438263 1719457 
 2010 Oct      127191     438263 1719457 

 24 rows selected 
Thanks everybody helps me. !!

may be using an external selection:

SQL> with sample_tab as
  2  (
  3  select  2009 year, 'Aug' month, 138776 summonth , 1720164  sumyear from dual union all
  4  select  2009,'Apr',130288,     1720164 from dual union all
  5  select  2009,'Dec', 140294 , 1720164  from dual union all
  6  select  2009,'Feb', 136422 , 1720164  from dual union all
  7  select  2009,'Jan', 148253 , 1720164  from dual union all
  8  select  2009,'Jul', 149842 , 1720164  from dual union all
  9  select  2009,'Jun', 122805 , 1720164  from dual union all
 10  select  2009,'Mar', 145872 , 1720164  from dual union all
 11  select  2009,'May', 151193 , 1720164  from dual union all
 12  select  2009,'Nov', 133487 , 1720164  from dual union all
 13  select  2009,'Oct', 169443 , 1720164  from dual union all
 14  select  2009,'Sep', 153489 , 1720164  from dual union all
 15  select  2010,'Apr', 142255 , 1719457  from dual union all
 16  select  2010,'Aug', 135894 , 1719457  from dual union all
 17  select  2010,'Dec', 171203 , 1719457  from dual union all
 18  select  2010,'Feb', 137011 , 1719457  from dual union all
 19  select  2010,'Jan', 145493 , 1719457  from dual union all
 20  select  2010,'Jul', 137474 , 1719457  from dual union all
 21  select  2010,'Jun', 154411 , 1719457  from dual union all
 22  select  2010,'Mar', 133062 , 1719457  from dual union all
 23  select  2010,'May', 146887 , 1719457  from dual union all
 24  select  2010,'Nov', 139869 , 1719457  from dual union all
 25  select  2010,'Oct', 127191 , 1719457  from dual union all
 26  select  2010,'Sep', 148707 , 1719457  from dual
 27  )
 28  select year,
 29         month,
 30         summonth,
 31         sum(summonth) over(partition by year || to_char(ym, 'Q') order by year || to_char(ym, 'Q')) sumquarter,
 32         sumyear
 33    from (
 34          select year,
 35                  month,
 36                  summonth,
 37                  sumyear,
 38                  to_date(year || month, 'YYYYMon') ym
 39            from sample_tab)
 40   order by ym
 41  ;

      YEAR MONTH   SUMMONTH SUMQUARTER    SUMYEAR
---------- ----- ---------- ---------- ----------
      2009 Jan       148253     430547    1720164
      2009 Feb       136422     430547    1720164
      2009 Mar       145872     430547    1720164
      2009 Apr       130288     404286    1720164
      2009 May       151193     404286    1720164
      2009 Jun       122805     404286    1720164
      2009 Jul       149842     442107    1720164
      2009 Aug       138776     442107    1720164
      2009 Sep       153489     442107    1720164
      2009 Oct       169443     443224    1720164
      2009 Nov       133487     443224    1720164
      2009 Dec       140294     443224    1720164
      2010 Jan       145493     415566    1719457
      2010 Feb       137011     415566    1719457
      2010 Mar       133062     415566    1719457
      2010 Apr       142255     443553    1719457
      2010 May       146887     443553    1719457
      2010 Jun       154411     443553    1719457
      2010 Jul       137474     422075    1719457
      2010 Aug       135894     422075    1719457

      YEAR MONTH   SUMMONTH SUMQUARTER    SUMYEAR
---------- ----- ---------- ---------- ----------
      2010 Sep       148707     422075    1719457
      2010 Oct       127191     438263    1719457
      2010 Nov       139869     438263    1719457
      2010 Dec       171203     438263    1719457

24 rows selected

SQL> 

Tags: Database

Similar Questions

  • How can I move my files and the operating system on a new hard disk on Inspiron 580 s.

    My hard drive failed Diagnostics recently and needs to be replaced.  I have since installed a new hard drive in Bay 2. I need to move everything from the old drive to the new drive and delete the old which is completed. So what is the best way to go about this?

    pjrl

    The simplest method, I prefer to install a replacement hard drive, is to clone the existing hard drive to the new, that will also transfer all applications and programs.

    You need an imaging utility, similar to True Image Home 2015.

    http://www.Acronis.com/homecomputing/products/TrueImage

    Acronis resize partitions transferred to match the size of the new hard drive.

    Hard drive manufacturers, also have their own free cloning software available, but it can be used only with their hard drives.

    First, install the new drive as the secondary and the image of the main hard drive in it.

    Immediately after the cloning, shut down the system, switch the data cable [SATA port 0] to the new disk, making the new master hard drive and see if the system boots properly.

    Start the system with only the new hard drive connected.

    Be sure to leave the original drive disconnected, until the new hard drive is working to your satisfaction.

    Before cloning a hard drive, make sure that the existing drive has no corruption or virus on it, because they will be transferred to the new hard drive.

    It will take a second SATA data cable, there should be a spare connector to SATA power inside the housing.

    Bev.

  • Why my display of the date of the mailbox does not have a / between the year and the month?

    I'm talking here about how the date of different e-mails appear in my Inbox. I have a / between the month and the day, and a / after the day, but I did not / between the year and the month.

    TB uses the date format short, such that defined by your operating system, which, in the case of Windows, is located in the Panel control/region and language.

    http://KB.mozillazine.org/Date_display_format

    There are a few modules that might also be useful:

    https://addons.Mozilla.org/en-us/Thunderbird/addon/ConfigDate/

    https://addons.Mozilla.org/en-us/Thunderbird/addon/Super-date-format/

    http://chrisramsden.vfast.co.UK/3_How_to_install_Add-ons_in_Thunderbird.html

  • can you help to reset the iPhone 6 +? used of the year and the month. Now, when you update, it asks activation and I can't remember anything! Arouca and verification is in stock

    can you help to reset the iPhone 6 +? used of the year and the month. Now, when you update, it asks activation and I can't remember anything! Arouca and verification is in stock

    To activate you need your Apple ID and password. If you forgot their date on https://iforgot.apple.com.

  • My wife and I bought hundreds of iTunes movies and music over the years. I have a terminal illness and won't last long. The account is in my name. How can I ensure that films and the songs that she and I have paid for are accessible for her after I spend

    My wife and I bought hundreds of iTunes movies and music over the years. I have a terminal illness and won't last long. The account is in my name. How can I ensure that films and the songs that she and I have paid for are accessible for her after I die?

    She needs to have your Apple ID and password. Your iCloud ID and the password if you have your own iOS device, so it can have access to these facilities. Even if she wanted to sell, it would need this information to remove the lock of activation before the sale.

  • How to complete the data or details of the only this year and the previous year for the given RATNG?

    Hi all

    I created a form with 5 blocks (namely ENQACMHDR, ENQACMDTL, ENQACEHDR, ENQACEDTL, ENQACSPEC), where I have 8 push buttons (namely ENTER_QUERY, EXEC_QUERY, CLEAR, FIRST, NEXT, PREVIOUS, LAST, and EXIT).

    This form is created just for display purposes only. So after that I ran, all blocks have been blocked against insert and update.

    I have question on 2 fields 'ENQNO' and "RATNG" (both belong to the ENQACMDTL block).

    When I click on "EXEC_QUERY" directly, all data for all years fills.

    But the user wanted the data to be populated only this year and the previous year.

    Yes, on ' Clause WHERE' of the property_palette of the 'ENQACMDTL' block , I put in the following condition:

    SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (ADD_MONTHS (SYSDATE,-12), 'YYYY') OR SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (SYSDATE, 'YYYY')

    PROPERTY PALETTE (ENQACMDTL block)
    WHERE ClauseSUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (ADD_MONTHS (SYSDATE,-12), 'YYYY') OR SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (SYSDATE, 'YYYY')


    Data only this year and the year before are now filled. Its ok with the field of "ENQNO".

    The problem is when I have queries on the field "RATNG. 'RATNG' is a Text_item with number of displayed items = 5. (5 lines)


    Here are the 2 columns in a Table (name = ENQACMDTL) in the database.


    ENQNO RATNG
    2013900054500KC2
    2013900047800KC4
    2013520018750KC6
    ...............
    20129000371000KC2
    2012520109500KC2
    2012140019750KC6
    ..................
    2011540036500KC2
    20111000301000KC2
    ..................
    .................
    200610000790KD8
    2006750014750KC6
    2006900072500KC2

    The first 4 issues of "ENQNO" represents the year. There is more than a lakhs of records.

    So, when I have queries on the field "RATNG."

    Example: for RATNG = 500KC2;

    I click on ENTER_QUERY, the field of "RATNG", I put in the 500KC2 of the value and click on EXEC_QUERY; Details regarding the 500KC2 is displayed as well as all the other junk RATNG as 750KC6, 1000KC2 (which belongs to the ENQNO of the current year and previous year) also gets displayed.

    I want details of only RATNG (500KC2) to display, but only for the current year and the previous year, it is 2013900054, 2012520109 (ENQNO).

    Other than 500KC2 RATNG, no other RATNG must be displayed.

    500KC2 = RATNG is also present for ENQNO = 2011540036, 2006900072. But I don't want them to view.

    I want only the data or details of the current year and the previous year to be filled or displayed for the given RATNG.

    Can you help me or tell me what I do for this?

    Hope I'm clear with my question!

    If my question is not clear, let me know please.

    Thank you.

    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

    Oracle forms 6i.

    1. check null values in the enqacmdtl.enqno, if so treat them properly.

    2. check the result of select to_char (add_months (sysdate,-12), 'YYYY') prev_year curr_year of double to_char(sysdate,'YYYY')

    3. change the place where clause "year" in the value of numAriques.

    where to_number (substr (enqacmdtl.enqno, 1, 4)) > = to_number (to_char (add_months (sysdate,-12), 'YYYY'))

    Then let me know the result.

  • How to re-enable my streets and the trial version of trip.

    How to re-enable my streets and the trial version of trip. I used it for 4 days.  I've been updating files on my computer and note the date was incorrect in a few years. I've corrected the date.  The next time I went to use the streets and trip he says my trial version expired :(     Is there a way to fix this so I can get my full trial period?

    HR_950

    Try the streets & trips Forum http://social.microsoft.com/Forums/en-US/streetsandtrips/threads

  • How can I move these indicator and the control to another page?

    How can I move these indicator and the control to another page? I page Kontrol and those on Installningar page, move!

    Or I want to hide them Kontrol page, how can I do

    Thank you

    Hi q8.

    move: select the controls, move them out of the container tab, drag them into the appropriate page of the tab container

    Hide: Terminal controls (!) right click, select "hide"...

  • How can I remove the user name and the image of Windows XP new Start Menu

    Two questions:

    1. How can I delete the user name and the image of Windows XP new start; and

    2. my computer keeps asking me to press the F1 key to start Windows.  How to skip this part?

    Thank you.

    Hello

    The image of user account can be removed by disabling the Welcome screen. Or, by opting for the classic Windows theme. Follow the method described in this article, if you want to remove the user name and the picture in the Start Menu, without disabling the Welcome screen and Windows XP theme.

    For those who want to delete the user name and the image of user account from the Start Menu, in order to have a blue white Panel at the top, try this:

    Registry warning
    Important: This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base:

    How to back up and restore the registry in Windows
    http://support.Microsoft.com/kb/322756/

    Step 1:

    a. start Windows Explorer and go to this folder:
     
    C:\Documents and Settings\All Users\Application Data\Microsoft account images

    b. in this folder, rename the BMP file that corresponds to your user account.
     
    (For example, if your user name is Robert, rename Robert.bmp to old_Robert.bmp)

    c. then rename the following folder:

    C:\Documents and Settings\All Users\Application Data\Microsoft account Pictures\Default pictures
     
    to something else, for example,.
     
    C:\Documents and Settings\All Users\Application Data\Microsoft account Pictures\No_Default images.

    Step 2:
     
    To remove the user name, follow these steps

    a. Click Start, click "RUN" and type "regedit.exe" and navigate to this key:
     
    HKEY_CURRENT_USER-Software-Windows Microsoft\------CurrentVersion-policies-Explorer

    b. in the right pane, the value NoUserNameInStartMenu-value data 1.

    c. close Regedit.exe and restart Windows.

    You'll find yourself with a blue area at the top of the Start Menu.

    Regarding the pressing 'F1' to start Windows, you have made no changes or was there a system crash after which the problem started?

    You may need to change the boot sequence in the BIOS to the default settings. I recommend you contact your PC vendor for this.

    Warning of the BIOS:
    BIOS change / semiconductor (CMOS) to complementary metal oxide settings can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the configuration of the BIOS/CMOS settings can be solved. Changes to settings are at your own risk.

  • I have 2 MacBook Pro, we are years and the other is 8 years old, I got photoshop cs2 on the former. After cleaning the disc hard I couldn't load the cs 2 on any of my laptops. Can I purchase an upgrade for it? I have all the DVDs, serial number and pack

    I have 2 MacBook Pro, we are years and the other is 8 years old, I got photoshop cs2 on the former. After cleaning the disc hard I couldn't load the cs 2 on any of my laptops. Can I purchase an upgrade for it? I have all the DVD, the serial number and packages, but I can't use it.

    Pricing plans and creative Cloud membership | Adobe Creative Cloud

  • How can I transfer CS5.1 (and the bridge and Lightroom4) an old iMac to a new?

    How can I transfer CS5.1 (and the bridge and Lightroom4) an old iMac to a new?

    You must not transfer you should install so that applications are properly set up with the machine.

    There are two options for downloading Lightroom 4:

    Mac: http://www.adobe.com/support/downloads/detail.jsp?ftpID=5566

    For what follows, remember to follow the steps described in the Note: very important Instructions in the section on the pages of this site download and have cookies turned on in your browser, otherwise the download will not work correctly.

    Lightroom 4: http://prodesigntools.com/adobe-lightroom-4-is-out.html#ddl

    CS5: http://prodesigntools.com/all-adobe-cs5-direct-download-links.html

  • have forgotten the administrative password and the need to create a new

    have forgotten the administrative password and the need to create a new, but without knowing an old failed to create a new

    your options are explained here

    Change or reset the password of a user account from OS X - Apple support

  • I bought a whole new office 27 "Mac provided with Adobe CS6. Everything worked like a charm until the 1 TB hard drive, developed a bad sector and the Apple Store reinstalled a new I had extended warranty with them. The recycled player I

    I bought a whole new office 27 "Mac provided with Adobe CS6. Everything worked like a charm until the 1 TB hard drive, developed a bad sector and the Apple Store reinstalled a new I had extended warranty with them. They are recycled the disc immediately (like crazy, I don't ask for this return to get the data off it.) But fortunately, I have all my data on CrashPlan. I downloaded it and it was working fine except that I downloaded it on the desk and not the original location so he had succeed. I also have an external 1.5 TB drive that I wanted to make it bootable, so I installed Mavericks 10.9.3. Then I advanced and installed on disk newly installed too.

    I think that because I have a new reader that adobe thinks, I have a new computer. I bought the 27 "Mac new on Ebay and it came loaded with the software, including CS6. I have a serial number for CS6, but Adobe says that it was not valid. (I've owned CS2 and CS4 now CS6 that came preloaded on the Mac by the seller who told me that the software has been registered for the Mac?

    I'll re - download the backup to the original location but this time (I still don't think that it will work with Adobe.) What can I do about it?

    iMac 27 inches, end of 2012

    Processor 3.2 GHz Intel Core i5

    Memory 32 GB 1600 MHz DDR3

    Graphics  NVIDIA GeForce GTX 1024 MB 675MX

    Software  OS X 10.9.3 (13D 65) @.

    You must contact Adobe Support by chat or phone when you have the serial number and activation problems.

    Here is a link to a page with options to help make contact:

    http://www.Adobe.com/support/download-install/supportinfo/

  • 12 months year in comparison to the year and the masking of the current month

    I have a question rearding Web Analytics, but I think it could be more essbase.

    I wrote a report that shows me the following:

    Jan-Feb-Mar-Apr - May - June - July - Aug - Sep - Oct - Nov - Dec
    This year 2012 5 5 5 5 5 5 1
    Year latest 2011 5 5 5 5 5 5 5 5 5 5 5 5

    My problem is that my data are met for all of last year and until July of this year, however I do not want to report of July of this year again, I would only report June, July is not yet closed. How can I tell the system that it's ok to report 12 months last year, but only to the report through June of this year. When I tried to hide June, he hid last years June as well.

    I have a dimension of the year and a period as well as the size of data dimension.

    Any help would be greatly appreciated.

    Thank you

    Paul

    Hi Paul

    It's how works the multidimensionality, I'm afraid that if you have periods in the years in rows and columns, then if you hide a period it will hide all years in your lines.

    According to what you need to your report to look like one option is years battery and periods in the columns, you can then use the skin work for the combination of "This Year" & "Jun".

    Other than that you're watching two calculations on the report or in the underlying database Essbase. Is it only specific reports that you want to or you have a general policy of only including including data for the periods completed / closed?

    If you have versions in your database, then you can create a 'Final' or 'Reports' version, then use a metric to set a flag 1 = report, #Mi = don't report and a calculation, so that your new version contains only data values for periods you want to report. If you do year over year variance rpeorting you could also build the flag to that.

    Hope this helps
    Stuart

  • How to get the same day of a month each year in the DB (update a flag)

    Hello

    I'm trying to make a update for a table of flag request in our database that contains the dates and the Pavilion columns. Currently the system have dates for the next ten years. The flags are updated with the values 0 or 1, if a particular date falls under the criteria required.

    I need to update the column flag for the same day of the month of each year. for example, 2nd Sunday of October. The value must be updated in all the years in the table. Currently I use the following query to update of the current year.

    UPDATE FILTERCALENDAR SET YEAR_WINDOW = 1 WHERE c_date = NEXT_DAY (TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1) * 7;

    and for the next year as

    UPDATE FILTERCALENDAR SET YEAR_WINDOW = 1 WHERE c_date = add_months (NEXT_DAY (TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1) * 7, + 12)-1;

    This isn't a great way to do it because he does not take care of leap years, and it does not scan and update values across the table for all the years correctly.

    Can someone help me fix this please.

    Welcome to the forum!

    Whenever you provide post your Oracle version 4-digit (result of SELECT * FROM V$ VERSION)
    >
    and for the next year as

    UPDATE FILTERCALENDAR SET YEAR_WINDOW = 1 WHERE c_date = add_months (NEXT_DAY (TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1) * 7, + 12)-1;
    >
    Why do you use "2013" in the TO_DATE for the year next rather than use simply '2014 '?

    You said it works
    >
    UPDATE FILTERCALENDAR SET YEAR_WINDOW = 1 WHERE c_date = NEXT_DAY (TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1) * 7;
    >
    Just interview the years from your table (list of the separate years) and use the query above on them.

    SELECT DISTINCT TO_CHAR(c_date, 'yyyy') FROM FILTERCALENDAR
    

    Or use this predicate

    WHERE c_date = next_day(last_day(add_months (c_date, -1)), 'SUNDAY') + 7
       AND TO_CHAR(c_date, 'mm') = '10'
    

    1 TO_CHAR ensures that the line has a month to October.
    2 ADD_MONTHS goes to Sept. 1.
    3 LAST_DAY going until the last day of September.
    4 NEXT_DAY goes to the first Sunday in October
    5 + 7 is going to the second Sunday in October

Maybe you are looking for

  • Why is apple tv (4th Gen) using subnet different comcast

    I need to figure out if there is anything special/different regaurding how ATV (4th Gen) made the resolution DNS when wired to a Comcast cable modem only (no wifi and no router)?  I notice that my ATV selects a different subnet when ATV is set automa

  • Why Firefox update when he knows, that it is not compatible with the extensions and plugins?

    Firefox now don't run videos or my birthday e-cards. I tried all solutions as much as I could but am not even remotely a techie to 61.Why do you insist on updates that make stuff that I use daily useless? Why do I have to remove or downgrade stuff to

  • Power problem with LG TV

    Hello I bought my Apple TV Gen 4 a few weeks ago and there is something I don't understand. It might be a nice feature, ATV turns the TV off automatically placing him on standby... but Apple thinks to, only users ATV maybe still a few other devices c

  • SBS 2011 Unmountable Boot Volume after a windows update

    Server crash after a windows update.  I don't know what update, it was 8.  Seemed to have completed successfully.  I restarted as requested.  After the restart, he came and said configuration of updates, 100% done and restarted again.  This time, no

  • Strange phone call

    I was contacted thid morning from someone who said he was from microsoft windows.  He said that my computer has been hacked and that it might crash.  He said he could help me if I did what he told me on the computer.  I was leary I had a hard time to