Get average number of duplicate records per user?

I am currently going through the activity log tables in the database to try and find out how many users make use of the application's batch processing functionality. As part of that, I'm trying to write a query to find out
the average number of activities each user has performed with each request, where a given request can have 1 (non-batch processing) or more (batch processing) records with an identical user ID and timestamp. Here's a simplified depiction of
the table in question:
LogEntryNumber
UserID
ActivityTime
1
1
2014-04-17 11:04:45.527
2
1
2014-04-17 11:04:45.527
3
1
2014-04-17 11:04:45.527
4
2
2014-04-30 07:52:39.243
5
2
2014-05-05 08:52:11.543
6
1
2014-05-13 08:41:09.173
7
3
2014-06-12 13:50:19.033
And here's the results I'd like to see:
UserID
AverageNumberOfActivitiesPerRequest
1
2
2
1
3
1
What would be the SQL query for getting these results?

One way
SELECT X.UserID
, AVG(X.C) AS AverageNumberOfActivitiesPerRequest
FROM (
SELECT UserID
, ActivityTime
, COUNT(*) AS C
FROM YourTable
GROUP BY UserID
, ActivityTime
) X
GROUP BY X.UserID
Edit: Actually that is doing an average on an integer so might not give you the results you expect - you can cast the COUNT(*) to NUMERIC/DECIMAL for better accuracy

Similar Messages

  • How can I get the number of distinct records that each field of a DB table has?

    Hi everyone,
    I would like to know how to get he number of distinct records that each field of a DB table has. When tracing a SQL statement either in ST12 or ST05, in the plan execution, if the sentence made useage of an index, then I can click in the index name and see this kind of information (no. of distinct values for each field of that index).
    Can I do something like this but with the whole fields of a table?
    What I have found until now is in Tx ST10; I search for whatever kind of table statistics and then use the function of "Analyze table" (which takes me to Tx DB05). In here, I can enter a table and up to 5 fields in order to get the information that I want.
    Is there any other way to do this?
    Regards,
    David Reza

    Hi David,
    You can export the same to excel and sort as per requirement.
    Sorry is that what you are looking for ?
    Regards,
    Deepanshu Sharma

  • Maximum number of email addresses per user

    I have a need to create a single mailbox with a large number of alias email addresses. I cannot find documentation on the maximum number of SMTP addresses that can be associated with a single user. Can someone point me in the right direction. Many thanks
    in advance!
    David

    Hi David,
    I've never heard of any restrictions about this, however, base on my search, I find a similar thread mentioned this question for your reference:
    https://social.technet.microsoft.com/Forums/office/en-US/2c167213-731d-439f-855e-2dcb1ffd1d31/maximum-number-of-email-addresses-per-user-exchange-2010-sp1?forum=exchangesvradminlegacy
    One member said:
    I could see one account with 1203 SMTP addresses. I cannot add more addresses, I get an error message when I try to add more. Maybe it is the limit. I´m still researching to be sure if it is a limit or not.The exchange is 2007.
    Best regards,
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Niko Cheng
    TechNet Community Support

  • Maximum number of spool requests per user

    Hello,
    I realise this question is a bit off-topic....
    We are experiencing problems with users that are creating 5000+ output requests in one time. As you can imagine, this is causing a lot of problems. Is there a possibility to limit the number of output requests per user?
    Pascal Ottens

    send them an email with a CC to their superiors   

  • How to get IDoc number using sdata records

    Hi Experts,
    I have executed a report program in background. Its generating few IDoc's. I can view those idoc's in WE05 also. But now i want to display those idoc number in the result output of the report. One of the segment having materrial number and plant details in the IDoc. Using this details i want to display the IDoc number in the output screen. Even i have tried with EDID4 table its taking huge time to get a single IDoc. Is there is any simplest way is there to get those idoc's .
    Otherwise how to achive this?
    Thanks and Regards,
    Mohana

    Hi,
    1.)If you want the ouput in the same report program which triggers the idoc, it is better to use the control record information.
    You will get IDoc Number from XEDIDC(check the below code) and you can store the idoc number into an internal table if more idoc is expecting to be triggered.
         call function 'MASTER_IDOC_DISTRIBUTE'
              exporting
                MASTER_IDOC_CONTROL        = EDIDC
              tables
                COMMUNICATION_IDOC_CONTROL = XEDIDC
                MASTER_IDOC_DATA           = XEDIDD
              exceptions
                others                     = 5.
       read table xedidc index 1.
      append xedidc-docno to it_docno.
    And finallly use this to display in the output.
    2.) if u want it in a seperate report, then select based on date, idoctype, messagetype
    Regards,
    Sajith

  • Number of data records per logical unit of works (LUW)

    When initialising opening stocks by default there are 5,000 data records per LUW.  For our extract this works out to 204 LUW.  Is there any optimium setting of number of LUW or data records per LUW? Thanks

    Niten
    See the below link
    URGENT! - Data Packet Size
    Assign points if has really helped you.
    Regs
    Gopi

  • Average number of searches conducted by users?

    Dear Sharepoint admins,
    I hope this is not too silly a question... but what is the average number of times users in your organization use search on Sharepoint on a daily/monthly basis?  (in the single digits? tens?
    twenties, hundreds...?)
    A colleague of mine is developing a integration for sharepoint that searches a knowledge database alongside internal searches, but wants to make sure we can handle the number of queries that
    might come through if this is launched. (and I can't find any statistics on these things)
    Any help is appreciated... thank you!

    It'll vary very heavily depending on how you're using SharePoint, how many users, how you organise the content. I've seen a SharePoint farm with 2TB of content which only had tens of searches a day because it was so heavily structured there wasn't a need
    for it. On the other hand i've seen ones which had hundreds or thousands of searches a day with a tiny fraction of the content.
    You will have to plan for the search volume but that tends to start from the number of users and the size of the content being searched.

  • How to get average number of emails per day?

    Hi,
    I need figures on the mail activity (whether inbound ir outbound). I have implemented the imslog.pl. Does this output from imslog.pl answer my question:
    Message load by day (dequeues):
    Date # of dequeues
    16-May-2006 8813
    the # of dequeues is the same as the number of outbound messages (mails that are sent by my mail server)?
    How to get the enqueued stats?
    thanks,

    Hi Linda,
    Email statistics are a tricky thing. Before attempting to collate statistics for any kind of reporting you need to strictly define what you wish to collect and how to define an 'email'.
    For example, if a single email is destined for 10 addresses, is this 1 email or 10. From a virus-scanning point-of-view it's one email, but from a storage perspective it can be 10 (single message store makes this even more complex) and from a delivery-to-external host it can be 5 (assuming 5 distinct email domains).
    For email activity, you can separate this into a few categories (this will also depend on your email infrastructure):
    a. Inbound external email (tcp_local enqueue)
    b. Inbound internal/external email from internal staff (tcp_submit/tcp_auth enqueue)
    c. Inbound internal email (tcp_intranet enqueue)
    d. Outbound external email (tcp_local dequeue)
    e. Local account delivered email (ims-ms dequeue)
    f. Local host delivered email (tcp_intranet dequeue)
    These statistics are all currently available in the imslog.pl output.
    Hopefully I haven't caused more confusion. I find though for reporting it is best to have these definitions clear from the beginning, especially if you are looking for trends over-time.
    Regards,
    Shane.

  • Server 2008 R2 RDP: limit max number of rdp connections per user group?

    Hello everyone,
    I have a Windows Server 2008 R2 with RDP installed.
    I want to create a couple of user groups which will have 5 different users in each. Then I would like to limit RDP connections, let's say 2 connections for the first group and 3 connections for the second group. For example, if 2 users from Group 1 are connected
    then when a 3rd user from Group 1 tries to connect it will be rejected to connect, but 3 users from Group 2 still can connect. Is it doable?
    Thanks in advance.

    Hi,
    I would like to check if you need further assistance.
    If you need help to create script, please post your questions in our related forums.
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home
    Thanks.
    Jeremy Wu
    TechNet Community Support

  • Can't limit the number of simultaneous sessions per user

    Hi,
    I am using Cisco ACS 4.0 as a radius server that authenticate users for Internet access.
    Microsoft ISA 2004 is used as Radius client.
    When users tries to connect to Internet, the ISA Server forwards requests to Radius server (Cisco ACS) for authentication.
    I have constated that some users communicates their passwords to permit acces to Internet for non authorized users.
    Even, I have selected Max Sessions property in Cisco ACS to 1 for every user, I can see clearly on ISA 2004 that the same user/password is used from multiple PCs simultaneously.
    Internet acess on my company is based on a user / password authentication, and IP adresses are provided by DHCP server.
    Can you help by advising me how to limit every user using the internet to only a single session at any time, by using ISA 2004 (proxy) and Cisco ACS 4.0 (Radius Server).
    Thank you.
    Mustapha.

    Limiting every user using the internet to only a single session at a time is not possible with a radius server. You will need to use the proxy server (ISA server) for this task.

  • How to get rid of duplicate records generated frm hierarchical cube in sql?

    Hi All,
    database version 10gR2.
    I am trying to aggregated data for two hierarchical dimensions, specifically organization and products.
    I am using one ROLLUP for each dimension, which would be two ROLLUP in GROUP BY clause to do the aggregation for every level of organization and product that are in included in the hierarchy.
    the troubling part is that that products that have data in corresponding fact table are not always located at the lowest level (which is 6) of the product hierarchy.
    e.g.
    product_id                               level
    0/01/0101/010102/01010201    5                           -->01010201, at level 5 , has data in fact table
    0/01/0101/010103                   4                           -->010103, at level 4, has data in fact table as well
    0/02/0201/020102/02010203/0201020304/020102030405              6   --> at level 6,(lowest level) and has data in fact table     we have a flat product hierarchy stored in table as below:
    prod_id  up_code_1 up_code_2 up_code_3   up_code_4   up_code_5 up_code_6
    01010201     0     01     0101     010102     01010201      NULL
    010103     0     01     0101     010103     null             nulldue to the NULL in product in level 6 for 01010201, when i run the query below, one duplicate record will be generated.
    for 010103, there will be 2 duplicate records, and for 020102030405 will be none.
    Encounter the same issue with the organizational dimension.
    currently, I am using DISTINCT to get rid of the duplicate records, but I don`t feel right to do it this way.
    So, I wonder if there is a more formal and standard way to do this?
    select distinct ORG_ID, DAY_ID,  TRADE_TYPE_ID, cust_id, PRODUCT_ID, QUANTITY_UNIT, COST_UNIT, SOURCE_ID,
          CONTRACT_AMOUNT, CONTRACT_COST, SALE_AMOUNT,SALE_COST, ACTUAL_AMOUNT, ACTUAL_COST, TRADE_COUNT
    from (     
    select  coalesce(UP_ORG_ID_6, UP_ORG_ID_5, UP_ORG_ID_4, UP_ORG_ID_3, UP_ORG_ID_2, UP_ORG_ID_1) as ORG_ID,
          a.day_id as day_id,        
          a.TRADE_TYPE_ID as TRADE_TYPE_ID,
          a.CUST_ID,
          coalesce(UP_CODE_6, UP_CODE_5, UP_CODE_4, UP_CODE_3, UP_CODE_2, UP_CODE_1) as product_id,
          QUANTITY_UNIT,
          COST_UNIT,
          A.SOURCE_ID as SOURCE_ID,
          SUM(CONTRACT_AMOUNT) as CONTRACT_AMOUNT,
          SUM(CONTRACT_COST) as CONTRACT_COST,
          SUM(SALE_AMOUNT) as SALE_AMOUNT,
          SUM(SALE_COST) as SALE_COST,
          SUM(ACTUAL_AMOUNT) as ACTUAL_AMOUNT,
          SUM(ACTUAL_COST) as ACTUAL_COST,
          SUM(TRADE_COUNT) as TRADE_COUNT     
    from DM_F_LO_SALE_DAY a, DM_D_ALL_ORG_FLAT B, DM_D_ALL_PROD_FLAT D --, DM_D_LO_CUST E
    where a.ORG_ID=B.ORG_ID
          and a.PRODUCT_ID=D.CODE
    group by rollup(UP_ORG_ID_1, UP_ORG_ID_2, UP_ORG_ID_3, UP_ORG_ID_4, UP_ORG_ID_5, UP_ORG_ID_6),
          a.TRADE_TYPE_ID,
          a.day_id,
          A.CUST_ID,
          rollup(UP_CODE_1, UP_CODE_2, UP_CODE_3, UP_CODE_4, UP_CODE_5, UP_CODE_6),
          a.QUANTITY_UNIT,
          a.COST_UNIT,
          a.SOURCE_ID );Note, GROUPING_ID seems not help, at least i didn`t find it useful in this scenario.
    any recommendation, links or ideas would be highly appreciated as always.
    Thanks

    anyone ever encounter this kind of problems?
    any thought would be appreciated.
    thanks

  • FORMS 9i issue: Is there a [b]SYSTEM build-in to get the number of records?

    In master-detail data blocks, a query generally return multiple records from the detail table. I'd like to know how to get the number of the records:
    1. I use NEXT_RECORD to navigate these records
    2. use SYSTEM.CURSOR_RECORD to know the current record
    3. use SYSTEM.LAST_RECORD to know when the last record is reached.
    What is missing is the total number of the records.
    Thank you in advance for helping

    My tip would also be the summary item

  • Limit the number of session per user in the Wired dot1x environment with ISE 1.2

    Hello,
    I need to check if there is any configuration/workaround to limit the number of sessions/access per user in the Wired dot1x configuration.
    I need to check if this feature is available or not to solve the following scenario:
    I have 2 SW ports configured to use dot1x authentication with ISE 1.2 server.
    If user A connects to the 1st port and authenticated then he will placed on a VLAN based on the authorization profile.
    The case, that I need to deny the same user to connect on a different machine with the same credentials.
    The ISE itself does not have this feature currently,  the only feature available is to limit the number of sessions for the guest user.
    Is there any workaround on the Cisco switches to solve this? Cisco WLC has this feature and for the VPN we can limit the number of sessions also from the ASA itself.
    Thanks.

    limit number of session per user using wired dot1x is not available in 1.3

  • Limit the number of records per page in webi

    Hello All,
    How do i limit the number of records per page in webi?
    i was asked to have not more than 20 records per page.
    In " NUmber of Vertical records per page"(Quick display mode) the default value was 100, i am trying to set it to 20 ...but its not updating....its still taking 100.
    I am on BO XI 3.1 Sp2 fix pack 3
    Please let me know a way to accomplish this.Any inputs appreciated
    Thanks

    It can be done as follows:
    1. create a variable at report level as:
            v Test = Floor(RowIndex()/20)
    2. Added this variable in the Block as a new column.
    3. Select the v Test column, Right Click and set as section (also you can apply break).
    4. Go to structure mode select section\break and go to properties tab and select the property "Start on new page".
    Regards,
    Rohit

  • How to change the maximum number of process per user in BW ?

    Hi,
    Do you know how to change the maximum number of process allowed per user ?
    With RSRT we can customize the number of process per query but I don't know where we can customize the maximum number of process per user.
    In fact, my production environment reach always the max number of process available in SM50...
    Thanks a lot

    Hi,
    A user is not have the No. of processor but a work process can handle N No. of users. If a user hit any transaction v acn say from  a list of N worl proceesor which has been taken the work.
    Correct if I am wrong.
    Regards
    Syed.

Maybe you are looking for

  • HT201210 my iphone is now in recovery mode... how do i set up as a new iphone?

    i got my daughter an iphone and she used her old itunes acct and now it turned her iphone into something like an ipod touch. It is now in recovery mode and was wondering now what? can she set up as a new iphone?  my internet connection ***** right no

  • Sky mobile tv

    Just got the n97 mini and cant connect to sky mobile.My internet works and bbc iplayer works but the app for sky mobile fails to connect. I got told by a lad in phones 4 u that he had the same problem on his x6,that some times it works and other time

  • Qosmio G10: Monitor completely blacked out

    Hello! I have this problem with my Qosmio G10, I turn on the laptop, the fan makes a high noise and finally it logs in Windows. Meanwhile, i cannot see what's happening, because the screen is blacked out. I just hear the sound for the Windows log on.

  • Active directory issue regarding time (DST) - Cant bind any Macs to 2000 AD

    I am working with a new server at a small mostly Windows based school district. I am here to do a small AD/OD integration with nothing out of the normal. They are using Windows 2000 server and 10.4.11 with all the current software updates. I tested b

  • How do I empty the spooler on my Photosmart 310A?

    I have several documents stuck in Queue on my 310A all in one. How do I empty them?