Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Get average number of duplicate records per user?

$
0
0

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 outthe 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:

LogEntryNumberUserIDActivityTime
112014-04-17 11:04:45.527
212014-04-17 11:04:45.527
312014-04-17 11:04:45.527
422014-04-30 07:52:39.243
522014-05-05 08:52:11.543
612014-05-13 08:41:09.173
732014-06-12 13:50:19.033

And here's the results I'd like to see:

UserIDAverageNumberOfActivitiesPerRequest
12
21
31

What would be the SQL query for getting these results?




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>