Group By Number of hours in a day

Hi
I need to write a SQL query to group by my records in hours of day.
For example -
00:00:00 - 00:59:59 - Some Data (There can be more than 1 row for each time slot)
00:00:00 - 00:59:59 - Some Data (There can be more than 1 row for each time slot)
00:00:00 - 00:59:59 - Some Data (There can be more than 1 row for each time slot)
01:00:00 - 01:59:59 - Some Data (There can be more than 1 row for each time slot)
01:00:00 - 01:59:59 - Some Data (There can be more than 1 row for each time slot)
02:00:00 - 02:59:59 - Some Data (There can be more than 1 row for each time slot)
23:00:00 - 23:59:59 - Some Data (There can be more than 1 row for each time slot)
23:00:00 - 23:59:59 - Some Data (There can be more than 1 row for each time slot)
23:00:00 - 23:59:59 - Some Data (There can be more than 1 row for each time slot)
Please advice

EXAMPLE
SQL> l
  1  select to_chaR(hh,'HH24' ), count(*)
  2  from
  3  ( select sysdate+level/23 hh from dual connect by level <125)
  4* group by to_chaR(hh,'HH24' )
SQL> /
TO   COUNT(*)
04          6
08          5
09          5
00          6
07          5
13          5
17          5
01          6
11          5
12          5
18          5
21          5
22          6
16          5
19          5
20          5
02          6
03          6
05          6
10          5
15          5
06          6
23          6
23 rows selected.

Similar Messages

  • Error  in Creation of Group Account Number Through FS00 or ob_glacc11

    Hi
    Experts
    I am creating group account number in fs00 nothing but group chart of accounts that can be done individually in fs00 or through ob_glacc11. There is balance in all the G/L accounts but for some particular G/L accounts the system is through.
    I am maintaining three ledgers one is for 16 periods, second one for 48 periods, third one is for 365 days.
    while running FS00 i am getting an runtime error : Packed field contains incorrect BCD format.
    DO glt0-rpmax  TIMES
         varying  saldo from glt0-hsl01 next glt0-hsl02.
         gesamtsaldo = gsamtsaldo + saldo.
    ENDDO.
    when i trace FS00 This glt0-rpmax is having value of 48. (periods) .
    please give me a solution how can i get the solution.
    Thanks in advance.

    Hi,
    You have activated group account number. If you have any grp account number of your company please provide the group company account number.
    Else if you dont want to give group account number
    In T-code: OB13 remove group chart of accounts from your chart of accounts
    Best Regards
    Ashish Jain
    Message was edited by:
            Ashish Bohara

  • SQL help: return number of records for each day of last month.

    Hi: I have records in the database with a field in the table which contains the Unix epoch time for each record. Letz say the Table name is ED and the field utime contains the Unix epoch time.
    Is there a way to get a count of number of records for each day of the last one month? Essentially I want a query which returns a list of count (number of records for each day) with the utime field containing the Unix epoch time. If a particular day does not have any records I want the query to return 0 for that day. I have no clue where to start. Would I need another table which has the list of days?
    Thanks
    Ray

    Peter: thanks. That helps but not completely.
    When I run the query to include only records for July using a statement such as following
    ============
    SELECT /*+ FIRST_ROWS */ COUNT(ED.UTIMESTAMP), TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD') AS DATA
    FROM EVENT_DATA ED
    WHERE AGENT_ID = 160
    AND (TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY')+(ED.UTIMESTAMP/86400)), 'MM/YYYY') = TO_CHAR(SYSDATE-15, 'MM/YYYY'))
    GROUP BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD')
    ORDER BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD');
    =============
    I get the following
    COUNT(ED.UTIMESTAMP) DATA
    1 07/20
    1 07/21
    1 07/24
    2 07/25
    2 07/27
    2 07/28
    2 07/29
    1 07/30
    2 07/31
    Some dates donot have any records and so no output. Is there a way to show the missing dates with a COUNT value = 0?
    Thanks
    Ray

  • Determining Hours Displayed in Day and Week View

    Hi there,
    Even though I have determined the Day hours to be, for example, 7am to 6pm in iCal Preferences, and I have determined the number of hours to be shown on the screen to be, for example, 11 hours, I still have to scroll down to fit my Day's hours in the view. In addition, the non-day hours (i.e. midnight to 7am, 6pm to midnight) are still being shown.
    Is there any way of removing the non-day hours, and in effect the scrollbar so that on opening iCal, the correct hours as I have determined them are displayed?
    Why would I want to open my Day or Week view and have at the top (what I would expect to be the first thing of my "Day") to in fact be Midnight (and go back to sleep)?
    Am I missing something or does this not work the way I think it should, or thought it did?

    See Fred Grieve's answer and John Maisey's solution here:
    http://discussions.apple.com/thread.jspa?threadID=1868347&tstart=0

  • How to configure JSpinner to accept number of hours (with mins and secs)

    I'm having a problem trying to figure out a simple way to enable a JSpinner to do allow the input in this format:
    n hours : n minutes : n seconds
    ex: 100 : 0 : 0, 1:59:59, 25:30:00
    Where n hours could be from 0-n (not restricted by 24 hours) and minutes and seconds are, of course, < 60. That is, I can enter number of hours, not a date, or a specific time in a day.
    I'm thinking the only way to do this is with a custom spinner model and custom editor? Or is there a simple way I can make the date model in spinner to allow me to do this?
    Thanks

    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    public class Test2 extends JFrame {
      public Test2() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        content.setLayout(new FlowLayout());
        content.add(new MySpinner());
        setSize(300, 300);
        setVisible(true);
      public static void main(String args[]) { new Test2(); }
    class MySpinner extends JSpinner {
      public MySpinner() {
        setModel(new SpinnerDateModel(
          new GregorianCalendar(2004,0,1,0,0,0).getTime(),
          null, null, Calendar.DAY_OF_YEAR));
        setEditor(new DateEditor(this,"HH:mm:ss"));
    }???

  • How to calculate Number of Hours between 2 dates

    Hi,
    I have a Column in a table of datatype DATE i.e. Update_Date. Now How do I calculate number of hours passed starting from this date entered in the Update_Date column to SYSDATE. e.g. if the date in column is 2-FEB-2009 and the sysdate is 2/2/2009 2:07:40 AM it should give me 24. How can I get this number of hours.
    Update_Date - Sysdate = Number of Hours.
    Thanks

    When you subtract two dates in Oracle, you get a difference in terms of days. Just multiply that by 24 to get hours.
    SELECT (sysdate - update_date) days,
           (sysdate - update_date) * 24 hours
      FROM your_tableThat said, it is not obvious how your example works. You state
    if the date in column is 2-FEB-2009 and the sysdate is 2/2/2009 2:07:40 AM it should give me 24Since both dates are on February 2, 2009, the only difference is in the time component. If we assume that the time component of the UPDATE_DATE value is midnight since it is not specified, there is a little more than 2 hours of difference between the two dates. How is it that you determine there are 24 hours of difference?
    Justin
    Edited by: Justin Cave on Feb 2, 2009 10:39 AM

  • Count number of hours between dates excluding holidays/weekends

    Hello all
    I havent worked with dates extensively and was recently asked to create a report where Im looking for the number of hours between two dates only counting business days.
    So for example I have data as follows
    Created 2011-03-30 15:00:00
    Processed 2011-03-30 15:03:46
    Fulfilled 2011-04-01 17:25:02
    Mailed     2011-04-01 17:45:00
    For a total of looking from the CREATED and MAILED dates
    50 hours 45 minutes
    Im also trying to exclude weekends and holidays, i was reading around and was actually able to also find a table of dates where I have the main date, HOLIDAY_IND column and WEEKDAY_IND column
    So the calender table i have looks similar to
    CALENDER_DATE HOLIDAY_IND WEEKDAY_IND
    2011-03-31 Y Y
    2011-04-01 N Y
    2011-04-02 N N
    Im really quite stumped as to where to begin
    I was thinking of trying to write it with PL/SQL but i dont have the proper user access to create procedures/functions, so looks like straight up SQL
    Any help appreciated!

    Hi,
    Depeneding on your data and your requirements, you can do something like this:
    SELECT     created_DATE,
    ,     mailed_date
    ,     24 * ( (mailed_date - created_date)
                SELECT  COUNT (*)
                FROM        table_o_dates
                WHERE    main_date > created_date
                AND        main_date < TRUNC (mailed_date)
                AND        (   holiday_ind = 'Y'
                         OR  weekday_ind = 'N'
               )               AS hours_between       
    FROM     table_x
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    What do you want to do if created_date or mailed_date is not a work day? Include examples in you data and results.

  • Last nonempty hour in previous day in SSAS

    Hello , 
    I have a requirement to get the last hour of previous day and compare it to the hours in current day in order to get the minimum . I have a date dimension and an hour dimension and a measure that calculated running total Qty . 
    The minimum on Saturday April 19 , 2014 should actually be 10 since it is less than 82 . if it was greater then we will take 82 . 
    I have tried to use the tail function , last child but nothing seemed to work . 
    Help is appreciated . 
    Thanks , 

    I was able to get the results I am looking for using the following measures , however the performance was really bad . the lastnonemptyday is populating a value for every single day .  
    Is there a way i could improve the performance or write the queries differently ? 
    CREATE
    MEMBER CURRENTCUBE.[Measures].[lastnonemptyhour]
    AS
    Tail(nonempty({null:[Hour].[Hour Number].currentmember}*[measures].[Allocated Quantity Running Total])).item(0),
    CREATE
    MEMBER CURRENTCUBE.[Measures].[lastchild1]
    AS ( [Hour].[Hour Number].Currentmember.lastchild,[Measures].[lastnonemptyhour])
    CREATE
    MEMBER CURRENTCUBE.[Measures].[lastnonemptyday]
    AS
    Tail(nonempty({null:[Date].[Calendar].currentmember}*[measures].[lastchild1])).item(0),
    CREATE
    MEMBER CURRENTCUBE.[Measures].[lastchild2]
    AS ( [Date].[Calendar].currentmember,[Measures].[lastnonemptyday]) ,
    CREATE
    MEMBER CURRENTCUBE.[Measures].[MIN]
    As
    IIF(([Date].[Calendar].prevmember,[Measures].[lastchild2]) < ([Measures].[Warehouse Min Inventory Allocated],[Date].[Calendar].currentmember),([Date].[Calendar].prevmember,[Measures].[lastchild2]),([Date].[Calendar].currentmember,[Measures].[Warehouse
    Min Inventory Allocated])) , 

  • FM to find the difference in the number of hours

    hi all,
    is there any function module to find out the difference between two time stamps on two different dates. say if an activity starts on 09/05/2007 at 11:23:24 and ends on 09/08/2008 at 14:24:26. it needs to find the number of hours between the two. for this case it should be:
    75:01:02 hours:mins:secs.
    or a FM which works in a way similar to the above functionality.

    Hi,
    Use FM SD_CALC_DURATION_FROM_DATETIME
    but this will not give the seconds difference
    Regards
    Shiva

  • How to find out the Group Delivery Number from STO

    User performed WA08 to create Vendor PO and STO for stores.
    When GR was carried out on the Vendor PO, multiple Delivery Order were auto-generated.
    Now, is there a place whereby User could identified the Group Delivery Number which
    links all the DOs generated based on either
    a. The STO number  OR
    b. The vendor PO number OR
    c. the allocation table.
    Can some assist?

    Hi,
    Please check these tables
    LIPS...
    VBELN: for Delivery Number
    VGBEL: for STO Number
    with the above chk this.
    VBSS...
    SAMMG: Group Number
    VBELN: Sales and Distribution Document Number
    Regards
    GK.

  • G/l Creation-asking for group account number

    Hello Gurus,
    I am creating G/l through Tcode FS00.But system pop the error .saying provide group account no I have not created any group account no please tell me how to create the group account number.
    Many Many Thanks

    Hi
    You create a group chart of accounts (OB13) and assign it to your operating chart of accounts. you can establish link between every GL account in your operating COA to GL accounts in group COA via gl master (FS01/02/03) via group chart of account field. If you choose to use ECCS (Enterprise Controlling-Consolidation) , then for each GL account in COA you need to create FS Items in ECCS module (1:1) and build the consolidated COA. Otherwise group COA can act as consolidated COA.
    You need Country COA if you need to meet reporting requirements of specific country. An MNC with operations in various countries can have a common COA (operating COA) to ensure standardisation of accounting, but use of operation COA doesnt help in meeting specific accounting countries of country of operation. this arises need for country COA and you can establish a link to each GL account in country COA to GL accounts in operating COA via gl master (FS01/02/03) via alternate chart of account field.
    So group COA sits on top to provide consolidated reporting (in much summarised form, cause 1 or more GL accounts in operating COA can be linked to 1 GL account in group COA) and then you have operating COA (to ensure standardised accounting across countries and facilitate cross company code controlling) and then alternate COA for meeting local requirements.
    Please go through the below mentioned related links
    Gl number in FS00
    GL Master DATA- FS00
    Hope this will help you to resolve your problem
    Regards
    Praveen P C

  • FI:where to maintain the data of "Group account number"?

    Hi.When I use the T-CODE FS00 to create G/L account,the sap require me to Make an entry in field "Group account number".But when I press F4 on the field "Group account number",the sap tell me there is no values.So I need to maintain the data of "Group account number".But I don't know where to maintain the data of "Group account number".So I need someone give me the T-CODE or some advice.Thanks so much.

    Hi,
    You have activated group account number. If you have any grp account number of your company please provide the group company account number.
    Else if you dont want to give group account number
    In T-code: OB13 remove group chart of accounts from your chart of accounts
    Best Regards
    Ashish Jain
    Message was edited by:
            Ashish Bohara

  • Group account number / Group Chart of Accounts

    Hi all,
    We have created a new group COA and have assigned it to the company COA.
    (In a production environment)  We have assigned the group COA number under the Group Account Number of the company COA.
    There is already transaction data's posted to these GL accounts for the entire year.
    1. How to update these transaction data's with the Group Account Number?
    2. Is there any program available to make this updating?
    Thanks in advance

    Hi
    Our client is planning to create a group account number and populate the group account number in the GL master.  They already have transactions posted to the group account number.
    But the question is how to populate the group account number on the historical trasnactions. Did you find a solution for this problem?
    Appreciate if you can provide the solution
    Thanks.....Bajee

  • Hi im having difficulty with my iphone 4s its been on charge for a number of hours and continues to flash the apple logo but will not turn on i have tried to reset but it did not help

    hi i am having difficulty with my iphone 4s it has been on charge for a number of hours but is just flashing the apple logo continuously i have tried to reset but nothing seems to work can anyone help me please

    What is a hard reset?  There is nothing in any of Apple's documentation that refers to a hard reset.
    There's a reset, a restart, and a restore.
    Please explain EXACTLY what you did.

  • Grouping of number range for Business Partner

    Hi Team,
    Where do we maintain grouping of number range for Business Partner and assignment of number range to group?
    Thanks,
    Sanjay

    Hi Sanjay
    Go to SPRO > Cross Application Components > SAP bussiness partner > Bussiness Partner > Basic Settings > Number Ranges and Groupings.
    Thanks
    pravin

Maybe you are looking for