Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sqldba01
Engaged Sweeper III

This can be used to get the most frequent logon account in the last 60 days. 

-- First query: Get the most frequent logon user for each AssetID

WITH LogonCounts

AS (SELECT AssetID,

username,

COUNT(*) AS logon_count,

ROW_NUMBER() OVER (PARTITION BY AssetID ORDER BY COUNT(*) DESC) AS rn

FROM tblCPlogoninfo

WHERE logontime >= DATEADD(DAY, -60, GETDATE())

GROUP BY AssetID,

username)

SELECT AssetID,

username AS PrimaryLogin,

logon_count

INTO #tempLogonInfo

FROM LogonCounts

WHERE rn = 1

ORDER BY AssetID;

 

0 REPLIES 0

Reports & Analytics

Ask about reports you're interested in and share reports you've created. Subscribe to receive daily updates of reports shared in the Community.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now