Grouping one year in three months

I have success to grouping in one month:
SELECT      A.colo1,     TO_CHAR(A.DATA_R,'MM')||' '||TO_CHAR(A.DATA_R,'MON') MESE, sum(a.col2)
FROM xxxxxxxxx A
     WHERE ........
     GROUP BY A.colo1,TO_CHAR(A.DATA_R,'MM')||' '||TO_CHAR(A.DATA_R,'MON')
but I am looking for  a solution to grouping every three months: e.g.
q1 01/01/2007 - 31/03/2007    100  
q2 01/04/2007 - 30/06/2007    200  
q3 01/07/2007 - 30/09/2007    1500
q4 01/10/2007 - 31/12/2007    2500 Thanks in advance for any help

SQL> create table xxxxxxxxx
  2  as
  3  select date '2007-01-01' data_r, 50 col2 from dual union all
  4  select date '2007-02-01', 20 from dual union all
  5  select date '2007-03-01', 30 from dual union all
  6  select date '2007-04-01', 120 from dual union all
  7  select date '2007-05-01', 40 from dual union all
  8  select date '2007-06-01', 40 from dual union all
  9  select date '2007-07-01', 500 from dual union all
10  select date '2007-08-01', 700 from dual union all
11  select date '2007-09-01', 300 from dual union all
12  select date '2007-10-01', 1200 from dual union all
13  select date '2007-11-01', 200 from dual union all
14  select date '2007-12-01', 1100 from dual
15  /
Tabel is aangemaakt.
SQL> select 'q' || to_char(a.data_r,'q') q
  2       , to_char(trunc(max(a.data_r),'q'),'dd/mm/yyyy') || ' - ' || to_char(add_months(trunc(max(a.data_r),'q'),3)-1,'dd/mm/yyyy') period
  3       , sum(a.col2)
  4    from xxxxxxxxx a
  5   group by to_char(a.data_r,'q')
  6  /
Q  PERIOD                  SUM(A.COL2)
q1 01/01/2007 - 31/03/2007         100
q2 01/04/2007 - 30/06/2007         200
q3 01/07/2007 - 30/09/2007        1500
q4 01/10/2007 - 31/12/2007        2500
4 rijen zijn geselecteerd.Regards,
Rob.

Similar Messages

  • Bought my iMac through Apple Education Pricing. Does this mean the warranty has been extended from the original one year to three years?

    Bought my iMac through Apple Education Pricing. Does this mean the warranty has been extended from the original one year to three years?

    No. If you want an extended warranty you still must purchase it. It is not included with education pricing.

  • Can't buy premium (ONE YEAR) only 1 month because ...

    Now, Skype is SOOOOOO BAD with "support".  I go to purchase premium, one year, and it WON'T LET ME!  it will only let me purchase 1 month because I only have $9 in account. SO, I go to add money to my account.  It only lets me add $10 at a time.  Now, I don't want to add a whole bunch of $10 hits to my VISA card or my bank will think it's stolen and put a hold on it.  So, I CAN'T BUY PREMIUM.  I sent a note to Skype LAST WEEK and the morons didn't understand the question and didn't answer it (just add money to your account!).  So, I CAN'T PURCHASE IT.  If only they had a valid competitor I would split in a second.  I dare say Skype is getting close to Ticketmaster-the most hated brand in America......anybody got any ideas?  Skype has no answers or abilities for me to even buy the ($*&%& service that my company wants me to have!  What a $*%& joke Skype. 

    Hi,
    I get it that you are upset about the payment amount limits, but please mind your language, otherwise your posts will be removed due to violation of community guidelines.
    About the issue itself, if you don't have enough Skype Credit on your account then of course you can't purchase Skype Premium for 12months with Skype Credit. Currently your account is new when it comes to payments and due to security reasons there are limits for amount you can pay at once. After you have made several successful payments over time these limits will increase.
    Instead of making several orders you can use your credit card to pay for Skype Premium with one payment. You don't need to first add credit to your account and then purchase, if you will be using credit card then why not use it for direct payment?
    I'll check what caused the miscommunication with customer service and see if there is anything customer service could have done differently to provide better service.
    Andre
    If answer was helpful please mark it with Kudos and if issue is resolved mark it with solution. This will help other users find this answer more easily. Thanks in advance!

  • Re: can't buy premium (ONE YEAR) only 1 month beca...

    I actually was trying to sign up for the one year service and see it is advertised as being 50% off, but when I went to the site, it was only 25% off. Is there someplace special you need to go on the site to get the additional discount?

    Hi,
    Some offers are country based, if you are either in US or Canada and 50% offer is not given then please contact customer service: https://support.skype.com/en/faq/FA1170/How-can-I-contact-Skype-Customer-Service
    Andre
    If answer was helpful please mark it with Kudos and if issue is resolved mark it with solution. This will help other users find this answer more easily. Thanks in advance!

  • One year month and year in Dashboard

    Hi experts,
    if i pass the input as 09.2014 in dashboard ,i need next one year date and month
    expample:
    input:  09.2014
    need like this 09.2014,10.2014,11.2014,12.2014,01.2014,02.2014,03.2014,04.2014,05.2014,06.2014,07.2014,08.2014
    suppose input is 01.2014
    need like this ,01.2014,02.2014,03.2014,04.2014,05.2014,06.2014,07.2014,08.2014,09.2014,10.2014,11.2014,12.2014
    I want dynamically ,below screen shot I have hard coded

    if you are using calendar component the the output of the calendar component is in datevalue()
    we have to convert that date 1st
    formula f6= text(f1,"MM/dd/yyyy")..............(09/15/2014)
    f7=text(f1,"MM.yyyy")....................(09.2014)
    after the we have to get next upcoming  12 month f9= text(eomonth(f6,11),"mm.yyyy")........(08.2014)
    and you the calmonth between operator while filter the query. 
    startdate = f7
    enddate = f9
    map this to prompt

  • Group by Month, Group By Year

    I have a date column in my table and it looks like 2009/06/29. Is there a way I can GROUP BY MONTH and GROUP BY YEAR on this column?
    Or do I have to create a YEAR column to GROUP BY YEAR, and a month column to GROUP BY MONTH?
    Thanks.

    When you insert a group on date field you will be having an option in group option "The section will be printed" For each month or year. So you can select for each month or week or quarter or year.
    Regards,
    Raghavendra

  • Hard Drive died under one year of replacement

    I replaced my Hard drive from Apple store this march and now its dead, will they replace it or I have to buy new one, I am not sure if the warrenty for new HDD is one year or six month if we replace through Apple store

    I just had a HD fail, it was an out of warranty repair since it was 22 days past my original 1-year warranty.  They took it on at their own expense since I was having problems with it some 2 or 3 months before the expiration.
    This was included in the receipt of service record:
    "All Apple products come with a one-year limited warranty and up to 90 days of complimentary telephone technical support."
    I assume this means this new replacement drive is covered for 1 year.
    https://supportprofile.apple.com/
    This PDF seems to say 90 days
    http://images.apple.com/legal/sales-support/terms/repair/docs/Retail_Repair_US_T erms_Conditions.pdf

  • Anyone know these devices come with a one year warranty ?

    My Network Extender stopped working a month ago, I travel alot for business so I didn't even notice it till i tried to make a call with my phone from my house.
    I called up Verizon and they said they would give me a new one at no cost, and the tech tried to place 5 orders in the system to get me this replacement device. All were canceled.
    Without notifying me that they were canceled, I had to find out by logging into my account, I was told the reason why was because their device that they sold me that was supposed to fix my issue with using my phone on there network was out of warranty, and I would have to pay 150 dollars more, one year and 2 months after I received their device.
    I asked if there was any supervisor that I could plead my case to and I was told that actually it was her supervisor who tried to push through this process and the verizon system would not allow it.
    My roommate's have a sprint extender, which was free, and works perfectly.
    In having a candid conversation with the tech who was excellent by the way, I discussed that it would be easier to add this device  to the punkin chunkin event, or perhaps go to a Verizon store and light in on fire in protest, or that I should buy one on EBAY with no understanding if it works before the purchase.
    So what I ask, is firstly why would the verizon team decided that charging me for a device to use their system is a smart business decision ?
    Did anyone get notified up front of a one year warranty on a device they force you to buy offering you a phony 75 dollar discount as the device retails foe 225 dollars by no one in their right mind would by one, if it werent for the horrible signal issues.
    I mean honestly, does anyone buy a baby seat for their car if they don't have babies ? Which might even be a better question..

    I totally understand that verizon isn't expected to work everywhere. The fact that it works at all we should be glad.
    Is there any device that you have owned, that comes with a one year warranty, maybe I am asking too much out of a device made by samsung?
    The Tech last night also explained to me that there are people on my street that have had to buy this device every year for 3 years.That says to me that their is an issue with the device, and that they shouldn't be charging us for it.
    I am looking at the sprint one on my desk right now, it is fully operational and was free.
    Do you think its correct that we should be charged for the device ? Considering in most cases, since people don't lock out telephones, everyone could take advantage of it in your neighborhood. so technically, I am allowing them to place a cell tower in my house, using my network connections to make their service better.

  • If you change the apple id on one device, is the id locked to that device for three months?

    I bought two ipod touches for my children last week (all kids under 10 if it makes a difference). Child #3 already has one. When I bought them, I was told that I can download movies on each for an upcoming long distance trip. If child 1 wants to watch something downloaded on child 2's ipod, they can sign in under child 2's account and watch it on their own ipod BUT it won't be saved to that device.
    However, I went in today to get them set up. I asked about this, and music and other things. I was told that if you sign in on one device under a different apple id, that device is locked to that apple id for three months. Its apparently an effort to stop pirating.  I was told its the same for music. If I buy a song on my account that my 5 year old wants, I have to buy it twice because if my son signs onto his ipod under my apple id, the ipod is then under my account for the next 3 months, along with all my games, music etc. and his apps are no longer accessible to him. 
    Is this acccurate? Honestly, I"m afraid to try. I don't want my kids to be stuck with my apple id, which has no apps or antyhing attached to it other than some music.
    BTW I had to set up their own itunes account despite that they're too young to have one because we're maxed at 5 devices (2 iphones, ipad and our own ipods). We couldn't add any others so I created a itunes account for my two youngest to share and a separate account for my 10 year old so that he could have his own facetime.
    Can anyone help? Can I sign onto my kids ipod with my id without having them locked out of their apps? Can the two of them share a movie?

    Not exactly but it is locked for the purpose of redownning past purchases. See:
    iTunes Store: Associating a device or computer to your Apple ID

  • GROUP BY GROUPING SETS for a selected month and for year to date

    Below is a code example to demonstrate this question:
    declare @test table (ID int, Quantity int, Day date);
    insert into @test values
    (4, 500, '1/18/2014'),
    (4, 550, '1/28/2014'),
    (7, 600, '1/10/2014'),
    (7, 750, '1/11/2014'),
    (7, 800, '1/20/2014'),
    (1, 100, '1/2/2014'),
    (1, 125, '1/10/2014'),
    (8, 300, '1/7/2014'),
    (9, 200, '1/17/2014'),
    (9, 100, '1/22/2014'),
    (4, 900, '2/18/2014'),
    (4, 550, '2/28/2014'),
    (7, 600, '2/10/2014'),
    (7, 700, '2/11/2014'),
    (7, 800, '2/20/2014'),
    (1, 100, '2/2/2014'),
    (1, 150, '2/10/2014'),
    (8, 300, '2/7/2014'),
    (9, 200, '2/17/2014'),
    (9, 100, '2/22/2014'),
    (4, 500, '3/18/2014'),
    (4, 550, '3/28/2014'),
    (7, 600, '3/10/2014'),
    (7, 750, '3/11/2014'),
    (7, 800, '3/20/2014'),
    (1, 100, '3/2/2014'),
    (1, 325, '3/10/2014'),
    (8, 300, '3/7/2014'),
    (9, 200, '3/17/2014'),
    (9, 100, '3/22/2014'),
    (4, 500, '4/18/2014'),
    (4, 550, '4/28/2014'),
    (7, 100, '4/10/2014'),
    (7, 750, '4/11/2014'),
    (7, 800, '4/20/2014'),
    (1, 100, '4/2/2014'),
    (1, 325, '4/10/2014'),
    (8, 300, '4/7/2014'),
    (9, 200, '4/17/2014'),
    (9, 100, '4/22/2014'),
    (4, 500, '5/18/2014'),
    (4, 550, '5/28/2014'),
    (7, 600, '5/10/2014'),
    (7, 750, '5/11/2014'),
    (7, 50, '5/20/2014'),
    (1, 100, '5/2/2014'),
    (1, 325, '5/10/2014'),
    (8, 300, '5/7/2014'),
    (9, 200, '5/17/2014'),
    (9, 100, '5/22/2014');
    --detail
    select *
    from @test;
    --aggregation
    select
    TotalQuantity = sum(Quantity),
    [Month] = month(Day)
    from @test
    group by
    grouping sets
    (month(Day)),
    (year(Day))
    go
    This is the aggregation query result:
    However, the desired result is to return only two rows: one row for month 3 and the other row for year to date (in the picture above YTD is the row that appears with {null} in the Month column).  Is there a way to achieve this goal by modifying the
    sample code above?  The requirement is to only read the data once (do not want a solution that involves a UNION which implies reading the data twice).

    you can add required filters in having clause. Here is the query -
    select
    TotalQuantity = sum(Quantity),
    [Month] = month(Day)
    from @test
    group by
    grouping sets
    (month(Day)),
    (year(Day))
    having
    month(Day) = 3 or month(Day) is null;

  • I am a Creative Cloud Member and have the Membership for one Year but in one month it syays expired

    I am a Creative Cloud Member and have the Membership for one Year. It has been only one Month and the Plan says expired. I am not sure what has happened but I am unable to find any Customer Care Number of Adobe.  Can anyone please help. Its Urgent. I use MAC.

    Moving this discussion to the Adobe Creative Cloud forum.
    Abhishek_zico you should be able to contact our support team at Contact Customer Care.  You will want to work directly with our support team regarding the status of your subscription.

  • First day of current month, one year ago

    All,
    Does anyone have a calculation or know how I can calculate the first day of the current month, one year ago? I am trying to setup a filter criteria to show all records created >= 1st day of current month for prior year and <= the last day of the prior month. I have the second half of the equation for last day prior month but need some help on the first half.
    Thanks in advance for any pointers!
    D

    You can try:
    SELECT TRUNC(ADD_MONTHS(sysdate, -12), 'MON') FROM dual;
    Or
    SELECT TRUNC(sysdate-NUMTOYMINTERVAL(1,'YEAR'), 'MON') FROM dual;

  • Good afternoon, I would like some information I have an ipod nano 6th generation and has the same one-year warranty is only 2 months of use, and it fell down and broke the glass of the display, I called technical assistance in Brazil and informed me that

    Good afternoon, I would like some information I have an ipod nano 6th generation and has the same one-year warranty is only 2 months of use, and it fell down and broke the glass of the display, I called technical assistance in Brazil and informed me that Brazil has no repair services for Apple, which was the basis of its price change in the exchange is not worth half the value of the product.
    I wonder how I do to change this device without the expense of 50% for the same product is in warranty?
    Thanks in advance.

    yes agree, plus a multinational seeing a product and has no technical assistance to do the maintenance then it's no use I buy a new product if it is damaged I will always be because it has no prejudice in this maintenance.
    sorry but even more products coming from China to Brazil in technical assistance.

  • HT204088 I was charged for a one year subscription just seconds after i agreed to purchase a 6 month subscription to Grindr and you can see they overlap please cancel  the order for the one year subscription.

    Tony I was charged twice for a product. I authorized one purchase for a 6 month subscription to Grindr and then I was also charged for a 1 year subscription please remove the one year subscription and refund my card... My bank said to go through apple to get the refund or it would be fraud and we would have to go through a long process. please help me out over 60$ is a lot of money for anyone ...
    thanks
    Anthony MAxcy
    <Email Edited by Host>

    We are fellow users here on these forums, you're not talking to iTunes Support - I've asked the hosts to remove your email address from your post's title (it's not a good idea to post personal info).
    You can try the 'report a problem' page to contact iTunes Support (I'm not sure if app subscriptions show on there): http://reportaproblem.apple.com
    If the 'report a problem' link doesn't work then you can try contacting iTunes support via this page : http://www.apple.com/support/itunes/contact/- click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Function to find the Last Date of Month One Year Ago - RETURNS ERROR

    I've written sql code which takes a date and finds the Last Day of the Month one year ago. For example,  it takes the date '2015-04-17' and returns the date '2014-04-30'. The code works fine in a query. Now I'm trying to turn this into a function. However,
    when I try to create the function I get the error:
    Operand type clash: date is incompatible with int
    Why is this error being returned?
    Here is my function:
    CREATE FUNCTION dbo.zEOM_LY_D(@Input Date)
           RETURNS date
    AS
    BEGIN;
      DECLARE @Result date;
      SET @Result =  convert(DATE, DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
        RETURN @Result;
    END;
    Thanks for any help you can give.
                     

    Stan,
    Thanks very much- that does the trick. I should have said I am using SQL 2008 so EOMONTH is not available to me. I still don't get why I got an error though, since I was treating a date like a date and not like an int.
    Thanks, John
    I think i found the issue but i do not know why it is causing the issue. i think may be the way dates are treated/stored internally..i think dates are stored as no of days after 0001/01/01 but cannot see how this cwould effect..may be somebody else can through
    some light..... 
    if you make it as datetime it will work,
    if you leave it as date - eliminate adding 1...  you should prefer to use dateadd to add/substract dates.
    try this to understand..
    --removed the +1 in the code
    declare @input date
    set @input ='20150503'
    select
    convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)),0)),101)
    go
    --made the datatype as datetime
    declare @input datetime
    set @input ='20150503'
    select
    convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
    Hope it Helps!!

Maybe you are looking for