Grouping Data Weekly

Hi,
I have a query in sql
Table employees
columns : empid,hiredate,job_id,salary
I want to count(empid) and group data weekly with job_id , order by month.
Sample of Data like :
mon week job_id count(empid)
jan week1 sa_rep 15
jan week2 sa_rep 20
jan week3 sa_rep 35
jan week4 sa_rep 40
feb week1 sa_rep 10
feb week2 sa_rep 05
feb week3 sa_rep 12
feb week4 sa_rep 15
Help please
Thanks and Regards,
Ramesh J C

you can
group by to_char(hiredate, 'IW'),  --week of year
              to_char(hiredate, 'Month')and
order by to_char(hiredate, 'Month')

Similar Messages

  • Group by week between date range

    Hi,
    i'm having a table for documents. The documents are received from diffeent dates. I've to calculate number of documents received on weekly basis.
    I need an sql to count the number of documents between two given dates grouping by weekly.
    My week starts on Sunday and ends with Saturday.
    I've tried group by with to_char(documentdate,'IW') , but this will take Monday to Sunday as a week & the incomlete weeks i'm not able to calculate. ie : in the below output the date range 1/28/2007 - 1/31/2007 is not a complete week . ( ie saturday to wednesday)
    I need out put should be like this for Date Range: 12/31/2006 to 1/31/2007
    week               count of documents
    12/31/2006 - 1/6/2007 10
    1/7/2007 - 1/13/2007     40
    1/14/2007 - 1/20/2007     30
    1/21/2007 - 1/27/2007     20
    1/28/2007 - 1/31/2007 10
    Please help me to get this.....
    (columns in documents table is documentid and documentdate)

    your're very close with IW. you just need to shift the data to get it to fall within the correct range. btw, you don't need julian dates. it's overkill
    trunc(date+1,'IW') will push the date into the correct week range (IW will put sunday one week earlier than you want, so push it ahead a day before truncating).
    then subtract 1 day from the result to get it to display with sunday's date instead of monday
    trunc(mydate+1, 'IW')-1
    and the week end date is simply trunc(mydate+1, 'IW')_5
    select mydate, to_char(mydate,'Dy') dy,
    trunc(mydate+1,'IW')-1 wk_Start,
    trunc(mydate+1,'IW')+5 wk_end
    from (select sysdate-rownum mydate from dual connect by level < 20)
    order by 1

  • Grouping Via Week Ending Date

    Hi All,
    I have transaction line data for each day for our customer and i would like to group via Week Ending date.  Our week runs from Sunday to Saturday.
    If i Add the transaction date to the group expert it allows me to group via week(perfect) but does it via week commencing.  I see you can group via formula, does any one know how you can get the grouping via Week Ending.
    thanks for any help and advise.
    mike

    Try using this formula...
    DateAdd("ww", DateDiff("ww", #1/6/1900#, {TableName.DateField}), #1/6/1900#)
    This formula will calculate the "Following Saturday" for any given date. If the date supplied is a Saturday, it will return that same date.
    So...
    11/2/2010 &gt; 11/6/2010
    11/13/2010 &gt; 11/13/2010
    11/14/2010 &gt; 11/20/2010
    HTH,
    Jason

  • Capacity requirement group by week

    Inside CM01, given a work center,  we can get capacity requirements group by weeks.
    Is there any function module to get the same answer?
    I've found that table KBED seems to hold the information I need.
    But don't know how to group the records into different slot of week.
    Can anybody help?
    Regards,
    Norman.

    Hi,
    user588757 wrote:
    Hi Frank,
    Too good... it worked !!!!!!!!!!!!Thanks. If it's too good, I suppose you can always add errors.
    And can we give input for END DATE...it does have only start date..Yes, you could give the end date instead of the start date.
    You could allow either.
    Suppose you had a form that returned user_input_date (a DATE) and a string, user_date_type, returned by a radio group, 'START' if the user indicated that the date entered was a start date, or 'END' otherwise.
    WITH  d  AS
        SELECT  user_input_date -     CASE
                             WHEN  user_date_type = 'START'
                             THEN  0
                             ELSE  6
                        END     AS input_startdate
    ,     g  AS
        SELECT  (creation_date - input_startdate)  AS wk_num
        FROM    xxsirf_per_addresses_tl
        CROSS JOIN  d
    SELECT    MAX (input_startdate + (7 * wk_num))          AS wk_start
    ,         MAX (input_startdate + (7 * wk_num) + 6)     AS wk_end
    ,         COUNT (*)
    FROM      g
    GROUP BY  wk_num
    ORDER BY  wk_num;Though if you were running this from a form, it would be easy to do sub-query d separately, and pass the input_startdate that it computed to the query I posted earlier.
    I would discourage allowing users to input both start- and end dates, because they won't necessarily be six days apart.
    Of course, you could ignore one if both were entered, but that's exactly the kind of thing that confuses end users.

  • Group by week

    Hi,
    I need to build a SQL Query that group data by week.
    for example :
    table looks like this
    the_date the_qty
    6/5/2002 1
    6/10/2002 4
    6/14/2002 5
    6/15/2002 36
    6/19/2002 76
    6/20/2002 88
    6/21/2002 88
    6/22/2002 24
    6/24/2002 53
    6/25/2002 281
    6/28/2002 2
    6/30/2002 3
    desired result
    6/9/2002 1
    6/16/2002 41
    6/23/2002 276
    6/30/2002 336
    7/7/2002 3
    thanks
    regards
    sunil

    Hi,
    use
    group by next_day(trunc(date_column-1),'SUNDAY')
    Best,
    EAThis is not correct.
    SELECT
         next_day(trunc(the_date-1),'SUNDAY')     the_date,
         SUM(the_qty)               the_qty
    FROM
         t
    GROUP BY
         next_day(trunc(the_date-1),'SUNDAY')
    THE_DATE        THE_QTY
    06/09/2002            1
    06/16/2002           45
    06/23/2002          276
    06/30/2002          339
    ... or group by trunc(yourdate,'W')trunc(yourdate,'W') will not produce the desired result in this case.
    SELECT
         TRUNC(the_date, 'W')     the_date,
         SUM(the_qty)          the_qty
    FROM
         t
    GROUP BY
         TRUNC(the_date, 'W')
    THE_DATE        THE_QTY
    06/01/2002            1
    06/08/2002            9
    06/15/2002          288
    06/22/2002          360
    06/29/2002            3

  • Help with excel grouped data and sorting to keep data intact

    I have a master spreadsheet with lots of data. I am trying to grouped the data based on physical address/city, add the values and once done sort it by valuation based on descending order by valuation but my data keep messing up.
    So in Row 1/col A: Address 1; Col B City: XXX; Col C: Valuation $$$
    Row 2/col A: Address 1; Col B City: XXX; Col C: Vauation $$$
    Row 3/col A: Address 2; COl B City: YYY; Col C:  Valuation $$$
    SO I sort by city and in ROw 1/2 same city with same address, I grouped it.  THen I created a new row below Row 3 and add up the grouped data (i.e. ROw 1 and 2).  I go through the entire list to finalize the grouped locations.  
    But when I am done and I sort by Valuation, all my data messed up coz I created a new row with addition of grouped location valuation and the formula gets messed up.
    Any one with ideas please help.  My deadline for this project is just a week away and I am freaking out.
    THanks in advance.

    it seems upload a sample is more clearly about the required.
    KR

  • [Forum FAQ] How do I export each group data to separated Excel files in Reporting Services?

    Introduction
    There is a scenario that a report grouped by one field for some reasons, then the users want to export each group data to separated Excel files. By default, we can directly export only one file at a time on report server. Is there a way that we can split
    the report based on the group, then export each report to Excel file?
    Solution
    To achieve this requirement, we can add a parameter with the group values to filter the report based on the group, then create a data-driven subscription for the report which get File name and parameter from the group values.
    In the report, create a parameter named Name which use the Name field as Available Values (supposing the group grouped on Name field).
    Add a filter as below in the corresponding tablix:
    Expression: [Name]
    Operator: =
    Value: [@Name]
    Deploy the report. Then create a data-driven subscription with Windows File Share delivery extension for the report in Report Manager.
    During the data-driven subscription, in the step 3, specify a query that returns the Name field with the values as the group in the report.
    In the step 4 (Specify delivery extension settings for Report Server FileShare), below “File name”option, select “Get the value from the database”, then select Name field.
    Below ‘Render Format’ option, select Excel as the static value.
    In the step 5, we can configure parameter Name “Get the value from the database”, then select Name field. 
    Then specify the subscription execute only one time.
    References:
    Create a Data-Driven Subscription
    Windows File Share Delivery in Reporting Services
    Applies to
    Reporting Services 2005
    Reporting Services 2008
    Reporting Services 2008 R2
    Reporting Services 2012
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thanks,
    Is this a supported scenario, or does it use unsupported features?
    For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
    in a supported way?
    Thanks! Josh

  • Start to finish, grouped data to xmlp

    Can anyone outline for me the best process by which I would query multi-level grouped data, generating subtotals in the database, and then pass that data to the XML publisher report, with the notion of grouping and subtotals communicated to the report? I don't want to perform the grouping in the report, as it involves large numbers of records. I can find in various places how to generate XML from the database using SQLX, but I don't understand how to get that XML to be used in a report as a datasource. I can paste it in as a query in the MS Word Template builder, but don't know how to get it into the XMLP Enterprise side of things.
    So, given this example query, could someone tell me how to get the data and the meaning of the data into XMLP?
    select emp.deptno,emp.mgr,emp.empno, sum(emp.sal)
    from emp inner join dept
    on (emp.deptno=dept.deptno)
    group by
    rollup(emp.deptno,emp.mgr,emp.empno)

    Oh, yes, I've tried...but I'm at a loss as to how to put the various pieces of XML Publisher together with a data template in the mix. Can anyone give an example of how one would actually go from my example query through data template and .rtf template to final report in XML Publisher Enterprise?

  • How to group data from two tables ?

    Hello,
    I have two tables and i want to group data from them but two table not linked.
    Table TEXT_IN : ID_IN (primary_key), DATE_IN
    Table TEXT_OUT : ID_OUT(primary_key),DATE_OUT
    Example :
    Result :Group Date and Order by IN,OUT
    And It seems a bit
    confusing because we do not link
    .You can give me solutions.
    Thank you.

    SELECT MAX(CASE WHEN Rn = 1 THEN [IN] END) AS [IN1],
    MAX(CASE WHEN Rn = 1 THEN [OUT] END) AS [OUT1],
    MAX(CASE WHEN Rn = 2 THEN [IN] END) AS [IN2],
    MAX(CASE WHEN Rn = 2 THEN [OUT] END) AS [OUT2],
    MAX(CASE WHEN Rn = 3 THEN [IN] END) AS [IN3],
    MAX(CASE WHEN Rn = 3 THEN [OUT] END) AS [OUT3],
    MAX(CASE WHEN Rn = 4 THEN [IN] END) AS [IN4],
    MAX(CASE WHEN Rn = 4 THEN [OUT] END) AS [OUT4],
    MAX(CASE WHEN Rn = 5 THEN [IN] END) AS [IN5],
    MAX(CASE WHEN Rn = 5 THEN [OUT] END) AS [OUT5],
    FROM
    SELECT COALESCE(m.DATE_IN,n.DATE_IN) AS DATE_IN,
    COALESCE(m.Seq,n.Seq) AS Seq,
    ID_IN AS [IN],
    ID_OUT AS [OUT],
    ROW_NUMBER() OVER (PARTITION BY Seq ORDER BY COALESCE(m.DATE_IN,n.DATE_IN)) AS Rn
    FROM
    SELECT ROW_NUMBER() OVER (PARTITION BY DATE_IN ORDER BY DATE_IN) AS Seq,*
    FROM TEXT_IN
    )m
    FULL OUTER JOIN
    SELECT ROW_NUMBER() OVER (PARTITION BY DATE_IN ORDER BY DATE_IN) AS Seq,*
    FROM TEXT_OUT
    )n
    ON n.Seq = m.Seq
    AND n.DATE_IN = m.DATE_IN
    )t
    GROUP BY Seq
    to make it dynamic see
    http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/dynamic-crosstab-with-multiple-pivot-columns.aspx
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to add a button to the grouped data in an AdvancedDataGrid?

    Hi,
    Can anyone please suggest how to add a button to the grouped data in the AdvancedDataGrid?
    I have tried extending the AdvancedDataGridGroupItemRenderer and using it as the groupItemRenderer but its not reflecting.
    For the leaf node the itemRenderer property works just fine.
    Please help!

    HI ,
    I want to add a push button on the ALV list out put which is comming as a pop up and I want this using classes and methods.
    I have got a method IF_SREL_BROWSER_COMMANDS~ADD_BUTTONS from class cl_gos_attachment_list  but still I am unable to get any additional button on the output ALV popup.
    Please help.
    Regards,
    Kavya.

  • Grouping data sent to servlet

    I have an applet servlet pair and I'm having trouble grouping the data coming in from various clients. Let's say there are five clients connected to the servlet on individual threads. The data from clients A, B, and C need to be grouped together, while the data from clients D and E are grouped together. In reality the exact groupings are determined at runtime by the users, but for out example let's say this is how it has worked out. My idea was to create for each group an instance of some class, let's call it simply "clientGroup" on the server that holds and processes the data for each client group. So data coming in from clients A, B or C would be placed into clientGroup1, while any data that came in from D and E would be placed in clientGroup2. To do this it seems that I need to send some sort of metadata with the actual data I'm sending from the applet to the servlet that instructs the servlet "put this data into clientGroup1" or whichever. Reflexivity seems only to be able to create new objects of class clientGroup, not reference and edit existing instances like clientGroup1 or clientGroup2. So what can I pass along with my data to instruct the servlet in which class instance to put the incoming data?

    At least you should be able to identify clients to check to which group they belong. The client should for example be logged in and its group ID should already be known at the server side. Or let the client pass a specific parameter indicating the group ID. If you can do that, then it is just easy. Declare an applicationwide Map somewhere where you use the group ID as key and the group data as value.

  • Grouping Data with JSP or JSTL

    Hi All,
    I would like to ask a question about how I can group data in JSP. Essentially, I have a DataBean (extends ArrayList) that is being returned to my JSP. The ArrayList contains HashTables. Please note that the JSP assumes the data is returned in sorted order. This JSP is not responsible for sorting the data itself.
    [UPDATED EXAMPLE]
    For example, here is what the data might look like:
    Column A Column B Column C
    1 2 3
    1 15 20
    4 5 6
    4 99 66
    7 8 9
    10 11 12
    Here is how I would use my DataBean:
    String column1Name =bundle.getString(�columnA.title�);
    String column2Name =bundle.getString("columnB.title");
    String column3Name =bundle.getString("columnC.title");
    /* Loop through the bean. */
    for (int i=1;i<myDataBean.size();i++) {
    Hashtable reportRow=myDataBean.get(i);
    String column1Value=reportRow.get(Constants.COLUMNA);
    String column2Value=reportRow.get(Constants.COLUMNB);
    String column3Value=reportRow.get(Constants.COLUMNC);
    }Question
    If I want to change my layout/display to group by a particular column. How would I do that without changing the data structure that is running my current DataBean? Below is an example of grouping by the values in ColumnA.
    ColumnA: 1
    ColumnB ColumnC
    2 3
    15 20
    ColumnA: 4
    ColumnB ColumnC
    5 6
    99 66
    ColumnA: 7
    ColumnB ColumnC
    8 9
    ColumnA: 10
    ColumnB ColumnC
    11 12
    Your help is very much appreciated.
    Thanks!

    Just curious, do people find my question unclear? Can I help clarify any points?

  • How to display group data only when the particular group is clicked

    Hi frnds,
    I want to design my report as follows:
    Data is grouped by country, and for each country it is showing details for that country. I need to find out a way to display all group names first.  E.g.
    Argentina
    Aruba
    Australia
    And on click of particular country name it should display its details below it
    e.g.
    -Argentina
         BBB            Mendoza          123456
    +Aruba
    +Australia
    Has anyone done that before??? Is it possible to achieve it through Crystal Report Designer (2008)?? If yes then how???
    A prompt reply would be appriciated as i need this information urgently.
    Thanx.

    Thanx Jehanzeb,
    The sample u suggested did not solve my problem since it is opening the group data in new window.
    My question is - can we show/hide group data by clicking on that particular group (under that group name).
    e.g.
    ->(initial display - only groups)
    + Australia
    + America
    + Bhutan
    ->(on clicking a group)
    + Australia
    \- America
    abc    xyx    12213213    wqe9090
    dsd    dcv     90eur90e    ifjjdioifdoi
    + Bhutan
    In short, I am looking for on-demand display of records grouped by some field and the expansion of data must be done in the same page.
    Edited by: Kuldeep Chitrakar on Aug 6, 2008 12:44 PM
    Edited by: Kuldeep Chitrakar on Aug 6, 2008 12:45 PM
    Edited by: Kuldeep Chitrakar on Aug 6, 2008 12:46 PM

  • Drill Down Report by Grouping Data

    I am using Apex version 4.
    I'm wondering if there's a way to create a drill down report by grouping data and having a plus (+) symbol (or some other symbol) next to the group so the end user can expand or collapse as they want. So similar to how it works in Microsoft Excel.
    So I'm looking to build a report that looks something like:
    Market Office Revenue
    1 $200
    a $50
    b $70
    c $30
    d $50
    So there would be a way to expand or collapse the list of offices.
    Anyone know of any way to do this? I was hoping to avoid having to create linked reports. Even if there's no way to get the expand/collapse functionality to work, it would be acceptable to just show the data as I have in my example above.
    Thanks.

    Sorry, the format of my example got messed up.
    It's basically a hierarchy between Market and Office. So it's Market 1, then underneath that it would be Office a, b, c, and d. One market, multiple offices. Total market revenue of $200, then each office has the amounts listed.
    Hope that makes sense.

  • Cisco ISE with AD Problem: "Could not read groups data: Global catalog not found"

    Hi all,
    When I make the ActiveDirectory integration with Cisco ISE, I have complete with this integration. but when I try to read the Groups from Active Directory, ISE shows the message "Could not read groups data: Global catalog not found".
    My Domain has multiple sites and subnets, each contains GC for local logon. I have set ISE to the correct site and subnet. Forward and Reverse DNS are working with no error.
    Does anyone get this problem, please help.
    I have check into the ISE CLI Reference Guide 1.1.x
    You are about to configure Active Directory settings.
    Are you sure you want to proceed? y/n [n]: y
    Parameter Name: dns.servers
    Parameter Value: 10.77.122.135
    Active Directory internal setting modification should only be performed if approved by ISE
    support. Please confirm this change has been approved y/n [n]: y
    What shoud I set in the Parameter Name ? dns.servers or my dns hostname ?
    Please suggest for this too.
    Thanks and Regards,
    Pongsatorn M.

    Hi Pongsatorn,
    Thanks for the reply!
    I've attached the results of the ISE detailed AD test. As you can see, there is a fair number of domain controllers in the AD forest.
    It seems everything works correctly until it gets to testing the AD connectivity on port 3268. Then I get this:
      Testing Active Directory connectivity:
        Global Catalog: pdascdc02.xyz.com
          gc:       3268/tcp - refused
      Testing Active Directory connectivity:
        Global Catalog: pdascdc02.xyz.com
          gc:       3268/tcp - refused
    For some reason, the request to the controllers on port 3268 is being refused.
    Any thoughts you might have are greatly appreciated.
    Cheers,
    Greg

Maybe you are looking for