So the following code produces a count of unique users grouped by week.
What I need to do is then from this data produce a running total of unique users to date, split by week. So in essence in week 1 there were 100 unique users, by the end of week 2 there were 200 unique users and so forth. I know I need to subquery the lot but since I'm am counting a distinct alphanumeric field ([user]) as opposed to summing a numeric I'm a little confuddled how to do this.
Pointers much appreciated.
Cheers, Paul.
Code:
SELECT TOP (100) PERCENT DATEPART(week, time_stamp) AS Week, COUNT(DISTINCT [user]) AS UnqCnt
FROM dbo.vw_ctrx_archive_ica_roundtrip_perf
WHERE (time_stamp BETWEEN GETDATE() - 120 AND GETDATE()) AND (dept_path LIKE 'All\XenApp Farms\AppName\%')
GROUP BY DATEPART(week, time_stamp)
ORDER BY week
Pointers much appreciated.
Cheers, Paul.