Soldato
I have a table with with a number of records but the key columns are UTCDate, USER and APPName.
This returns the last entry for each user for each AppName. However, I would like to return the last entry for each user for every week. Nesting another subquery is the part which is confusing me. Any pointers much appreciated.
TIA!
Code:
SELECT *, DATEPART(week, utcDate) AS WEEKNO
FROM (SELECT *, row_number() OVER (partition BY user, AppName
ORDER BY utcDate DESC) AS rn
FROM dbo.sometable) a
WHERE a.rn = 1
TIA!