How to count transactions by mutiple days (group by two days)

Hi,
I am looking for a SQL solution which provides count of transactions by two days / three days etc. (e.g. GROUP BY two days).
I tried the following approach
select
id
, counT(*) OVER (PARTITION BY trunc(date_field) + INTERVAL '1' DAY)
from tablename
However this would give me count for each row in the table. I am looking for a solution, which provides me one row for each two days interval
Appreciate your help..

Hi,
If you want to collapse the results down to one row per unique value of day_breaker (and, depending on your requirements, id) then use the aggregate SUM function; it's simpler than the analytic SUM.
MIN (day_breaker) may not be the first day of the period. For example, if you add this row to your sample data:
insert into TEST_X (id, trans_id, date_field)
     values     (1,  6,        TO_DATE('01/06/2012','mm/dd/yyyy'))
/then the output will contain these day_breakers:
1/1/2012
1/3/2012
1/6/2012          (not 1/5/2012)Try this:
WITH     got_day_breaker     AS
     SELECT     id, trans_id
     ,     date_field          -- For debugging only
     ,     DATE '2012-01-01' + ( 2 * FLOOR ( (date_field - DATE '2012-01-01')
                              / 2
                        )     AS day_breaker
     FROM     test_x
SELECT       id
,       day_breaker
,       COUNT (*)     AS cnt
FROM       got_day_breaker
GROUP BY  id
,       day_breaker
ORDER BY  id
,       day_breaker
;

Similar Messages

  • How to assign transaction code to report group.

    hi experts,
      i used report painter to create some reports and assign these reports to a report group, i want to assign a transaction code to the report group, how can i do that? hunger for your adivces, thanks a lot!!

    Hi Liu,
    when you change an area menu, you can add transactions that launch ABAP/4 reports, Query lists or report writer's. You can use it for your purpose:
    1. Enter transaction SE43 and change a Z* area menu (no matter which one, you will not change it in the end)
    2. Click on "Add entry as subnode" or "Add entry at the same level" (no matter which one of them)
    3. When SAP shows the popup "Add new entries", click on "Add report"
    4. On the next popup, click on radio-button "Report Writer". Then you will be asked foe the code of the report group.
    5. Then save, and... that's it! SAP will automatically create a transaction for the report group
    6. Now you can cancel the changing of the area menu
    I hope this helps. Best regards,
    Alvaro

  • Synching Calendar shows all day events over two days

    Hello, been playing around with this for the last hour.
    I run entourage and sync calendar events via itunes no problems, but today i noticed that some events for example birthdays were running across two days, checked them in calendar and they are fine, also check the events in ical and they are all set as one day.
    When i synch the phone, i get an event running across two days????
    tried various options, removing from one an sycnhing back and to, removed evertyhing from iphone and chose in itunes to Replace information on this iphone yet events are two days. Edit them on the phone and resynch and they appear again as two days.
    Any suggestions?
    Thanks for any advice offered?

    I did, and said that there are others. I did not however specify a specific thread.
    Is there some reason why you cannot search for answers using the search facility ?
    Its not difficult - just like using Google. there are a few threads i have seen in the last week or so, but I'm too lazy to point them out for you.

  • All day events spanning two days

    I have a Nokia 6300 that I'm syncing with iCal but when I have an all day event in iCal it comes in as a timed event on the phone that runs from 13:00 on one day and then ends 13:00 the following day. Whereas if I add an all day event on the phone then it transfers into iCal perfectly ok. Any ideas?

    In the UK we're actually at GMT +1 hour to account for BST.
    http://www.timeanddate.com/worldclock/city.html?n=136
    Try setting your phone to that instead and see what happens.

  • How can I change the reminder time of an all day event?

    How can I make an all day event remind me the evening before.  The only reminder options are 9:00 the day of (which is too late) or 9:00 the day before (which gives you a whole day to forget about it).  Why can I not select when I want a reminder?  I have tried both alert tab in the event itself, and the default alert setting under settings/mail, contacts, calendars/default alert times. 

    THis is what I do, and it works for me.....I create two entries. Yes, it is extra work, but it works.  The first one is the all-day event.  I set that to remind me the day before and two days before.
    Then the second entry I set a time on the day, and in the Title Box, I put "reminder about "insert date here". Then I set that to remind me according to hour(s) or minutes before.
    IF I want a reminder inconsistent with those, I simply set the start date/time for the actual hour I want to be reminded, even if it is say "11:00pm the night before"  when it goes off, I just reset it using the roll thing to the next date/time that I want it to go off.
    I am a newbie and still have my old-fashioned paper planner, fully filled out, but find the calendar feature of the iPhone so absolutely useful. As well as the notes. Mainly when I am out and about. I used to tote my book around, now I just enter it on my phone, make myself a note, and then enter the info in my book later on. Paperless society, I doubt that'll happen, but technological devices sure fit in your pocket more easily...
    BTw- have you noticed that if you put in a birthday of a contact in Contacts, it will show up in your calendar with a little present icon?
    (= Have a happy day! =)

  • Count the number of values in a two dimensional array

    i am trying to figure out how to count the number of values in a two dimensional array.
    numScores = student[i][j].length;This doesn't work, i am trying to find a way of counting the columns

    Object[][] o;
    int tot = 0;
    for(int x = 0 ; x < o.length ; x++)
       tot += o[x].length;
    }If it's not a jagged array, however, this would be easier:
    int tot = o.length * o[0].length;

  • EXPORT SETTINGS FOR TWO-DAY SEMINAR- HELP

    Does anyone know how the best export settings using compressor for a two-day training/seminar video? There's about 12hours total that need to be burned to DVD.

    You're going to have to break this down to multiple DVD's. Everyone NEEDS a bathroom break about every 2 hours-- so it looks like 6 dvd's.
    There is absolutely no reason to even try to put this on one disc.

  • ST03 displays statistics data just for two days ago

    Dear All,
    I'm a newbie in sap.
    In my SAP SOLMAN server, there's no statistical record when I enter STAD for today.
    And, inside ST03, last workload records was two days ago.
    I've checked that the SAP_COLLECTOR_FOR_PERFMONITOR scheduled per hour and finished successfully. I've also tried to restart the SAPOSCOL, upgrade to the newest SAPOSCOL, but the problem is still occured.
    Several days ago, I deleted the Statistic Records using ST03, hope it would refresh the statistics, but the new statistics only created for a few hours, then it stopped, and continued the next two days with old two days data.
    How to make this back to normal ?
    Any suggestions?
    Thank you very much

    Hi
    Check your client time setting
    it  is European timing  change in India times
    through SPRO
    it is help out
    Regards
    Jay

  • How to count records in a page which are in detail section

    Hi
    Is there a option to count records in detail section and so that based on that can apply a formula.

    Hi
    can i place the below two formulas in section experpt ?
    my report is like
    gh#1 
    details-----which contains transactions related to above group for a country
    group footer#1contains line '--
    if for india there are 3 records in the same page there can be 2 or 3 records in detail section. like that a page can contain more than one country. if number of records are more and coming in next page then the whole section should be moved to new page.
    that is my req. can u suggest accordingly.....
    i want to count the number of records in detais which will vary also how can i put formula when they are going to next page?

  • How do i invite more than one invitee on different days for the same event

    Hi all,
    I basically want to create one event that occurs on several months with a group.  I know how to invite lots of people on one day but not several days.
    Please advise.
    Thanks

    hi Abbey!
    just checking. have you seen these user tips and KB docs yet?
    Natalie Beresford: multiple iPod/iTunes installations
    How to use multiple iPods with one computer
    iTunes: How to share music between different accounts on a single computer
    keep us posted.
    love, b

  • My wife's Apple ID is shown as belonging to a family sharing group, but we can't determine what is the id of the owner.  How can she remove herself from the group?

    my wife's apple ID is shown as belonging to another family sharing group. We can' t figure out the  Apple ID of the 'owner' of the group.  Is there any way to remove oneself from a family sharing group when you are not the owner?  Or how can we find the log in id (Apple ID) of the owner?

    i partially solved the problem, however still need some help.  My wife has made purchases under two different Apple ids.  I tried t re-set her iPad with her main ID but it is apparently part of a family.  I re-set  her iPad iCloud using her secondary ID.  The sharing of iTunes shows her main apple ID.  The settings iTunes is also set to her main Apple id.  I sent an invite from her iPad icloud family sharing to her main Apple ID, but when I attempted to consent to join it says she is already a member.  So I am guessing this is because in the family set up under her secondary ID that her main id is the iTunes account that is shared.  My question is could I change the iTunes shared under her name as owner to her secondary account, then invite her main account to join as a distinct member?  I am nervous about doing this for two reasons 1.  There is a warning when changing the shared iTunes account that says you can't join another group for 90 days. 2. I may still get the message that her main account is still a member of the group even though it doesn't show up, and then not able to revert back.
    if you follow this can someone offer some help,
    thanks
    note. This whole problem when we had to change a Apple id when we changed Internet service providers.

  • How to Count number of rows

    Hi All
    If I have 2 tables with records in it, with primary Table A and Foreign key Table B structure.Then how to count the no of occurances of each records of table A in table B and print the values.
    Thanx

    Hi,
    If I understood you can a query like this:
    SGMS@ORACLE10> create table a (cod number);
    Table created.
    SGMS@ORACLE10> create table b (cod number,id number);
    Table created.
    SGMS@ORACLE10> alter table a add constraint pk_a primary key (cod);
    Table altered.
    SGMS@ORACLE10> alter table b add constraint fk_b_a foreign key (cod) references a;
    Table altered.
    SGMS@ORACLE10> insert into a values (1);
    1 row created.
    SGMS@ORACLE10> insert into a values (2);
    1 row created.
    SGMS@ORACLE10> insert into a values (3);
    1 row created.
    SGMS@ORACLE10> insert into b values (1,1);
    1 row created.
    SGMS@ORACLE10> insert into b values (1,2);
    1 row created.
    SGMS@ORACLE10> insert into b values (1,3);
    1 row created.
    SGMS@ORACLE10> insert into b values (2,1);
    1 row created.
    SGMS@ORACLE10> insert into b values (3,1);
    1 row created.
    SGMS@ORACLE10> insert into b values (3,2);
    1 row created.
    SGMS@ORACLE10> commit;
    SGMS@ORACLE10> select b.cod,count(*) from b,a where a.cod = b.cod group by b.cod;
           COD   COUNT(*)
             1          3
             2          1
             3          2
    SGMS@ORACLE10>Cheers

  • How to count Number of  completed instances

    Hi all,
    I have one issue regarding *"How to Count Completed instances"* in SOA...
    How can i count the number of completed instances for a interface...Any idea or suggestion plzzzzzz....
    Thanks,
    Raj

    Hi Dariel Pérez ,
    By executing the Querey I'm able to get the State and num_cube instances but when I call this Query in BPEL by using DB adapter I get the following error
    BINDING.JCA-12563 Exception occured when binding was invoked. Exception occured during invocation of JCA binding: “JCA Binding execute of Reference operation ‘CountReq’ failed due to: Pure SQL Exception. Pure SQL Execute of SELECT (CASE WHEN STATE=1 THEN ‘OPEN AND RUNNING’ WHEN STATE=2 THEN ‘OPEN AND SUSPENDED’ WHEN STATE=3 THEN ‘OPEN AND FAULTED’ WHEN STATE=4 THEN ‘CLOSED AND PENDING’ WHEN STATE=5 THEN ‘CLOSED AND COMPLETED’ WHEN STATE=6 THEN ‘CLOSED AND FAUTED’ WHEN STATE=7 THEN ‘CLOSED AND CANCELLED’ WHEN STATE=8 THEN ‘CLOSED AND ABORTED’ WHEN STATE=9 THEN ‘CLOSED AND STALE’ WHEN STATE=10 THEN ‘NON-RECOVERABLE’ ELSE STATE || ” END) AS STATE, COUNT(*) AS NUM_OF_CUBE_INST FROM CUBE_INSTANCE GROUP BY STATE; failed. Caused by java.sql.SQLSyntaxErrorException: ORA-00911: invalid character . The Pure SQL option is for border use cases only and provides simple yet minimal functionality. Possibly try the “Perform an operation on a table” option instead. This exception is considered not retriable, likely due to a modelling mistake. To classify it as retriable instead add property nonRetriableErrorCodes with value “-911″ to your deployment descriptor (i.e. weblogic-ra.xml). To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff. All properties are integers. “. The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
    Any Suggetions.
    Thanks
    Mani

  • Please help me how to check a material does existed group code in system (w

    Hi all,
    Please help me...
    I have inputted quantity for  tx MC 94  but when I input them into  tx MC94, I met  a message " Structure  not yet maintained for  this conbination characterstics". Step by step to show a error message as below:
    Step 1: Launch MC 94
    step 2: Enter Planning
    Step 3: Enter  Prod.Code. Material (ex: enter material code :0101010260008, this code is existed  Prod.Code )
    Step 4: Click on "Inactive Version " button
    ==> A error message is showed.
    Please help me how to check a material does existed group code in system (which table to  check  it)?
    How to record the message" Structure  not yet maintained for  this conbination characterstics" to catch up it in my program?
    Thank in advance.

    Karenloria,
    1. Check in MC8C, which Infostructure is used for Planning type "Planning" or the one you are entering in the intial screen of MC94.
    2. Using transaction MC63 for the infostructure identified in step 1, check the planning hierarchy maintained. If this product is not maintined maintain using MC62.
    You can also check using SE16 transction the current infostructe records(Plan) for the table name = infostructure identified in step 1.
    Regards,
    Prasobh

  • Transaction code to change group indicator & group number of a routine

    Transaction code to change group indicator & group number of a routine

    Post Author: paul.carpenter
    CA Forum: Formula
    Sorry for the ignorance.  I did a little more playing, created a group summary count, then checked it against my record count per group.
    All set now!

Maybe you are looking for