→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎01-21-2016 08:34 AM
Solved! Go to Solution.
‎01-22-2016 11:21 AM
Select Top 1000000 SubQuery2.Username,
SubQuery2.Userdomain,
tblADusers.Department,
SubQuery2.LogonCount,
tblAssets.AssetName,
tblAssets.Domain,
tblAssets.AssetID,
tblAssets.IPAddress
From (Select Top 1000000 SubQuery.Username,
SubQuery.Userdomain,
Max(SubQuery.Count) As LogonCount
From (Select Top 1000000 tblCPlogoninfo.Username,
tblCPlogoninfo.Domain As Userdomain,
tblCPlogoninfo.AssetID As ID,
Count(tblCPlogoninfo.ID) As Count
From tblCPlogoninfo
Group By tblCPlogoninfo.Username,
tblCPlogoninfo.Domain,
tblCPlogoninfo.AssetID) SubQuery
Group By SubQuery.Username,
SubQuery.Userdomain) SubQuery2
Inner Join (Select Top 1000000 tblCPlogoninfo.Username,
tblCPlogoninfo.Domain As Userdomain,
tblCPlogoninfo.AssetID As ID,
Count(tblCPlogoninfo.ID) As Count
From tblCPlogoninfo
Group By tblCPlogoninfo.Username,
tblCPlogoninfo.Domain,
tblCPlogoninfo.AssetID) SubQuery3 On SubQuery3.Username = SubQuery2.Username
And SubQuery3.Userdomain = SubQuery2.Userdomain And SubQuery3.Count =
SubQuery2.LogonCount
Inner Join tblAssets On tblAssets.AssetID = SubQuery3.ID
Inner Join tblADusers On tblADusers.Username = SubQuery2.Username And
tblADusers.Userdomain = SubQuery2.Userdomain
Order By SubQuery2.Userdomain,
SubQuery2.Username
‎01-22-2016 11:21 AM
Select Top 1000000 SubQuery2.Username,
SubQuery2.Userdomain,
tblADusers.Department,
SubQuery2.LogonCount,
tblAssets.AssetName,
tblAssets.Domain,
tblAssets.AssetID,
tblAssets.IPAddress
From (Select Top 1000000 SubQuery.Username,
SubQuery.Userdomain,
Max(SubQuery.Count) As LogonCount
From (Select Top 1000000 tblCPlogoninfo.Username,
tblCPlogoninfo.Domain As Userdomain,
tblCPlogoninfo.AssetID As ID,
Count(tblCPlogoninfo.ID) As Count
From tblCPlogoninfo
Group By tblCPlogoninfo.Username,
tblCPlogoninfo.Domain,
tblCPlogoninfo.AssetID) SubQuery
Group By SubQuery.Username,
SubQuery.Userdomain) SubQuery2
Inner Join (Select Top 1000000 tblCPlogoninfo.Username,
tblCPlogoninfo.Domain As Userdomain,
tblCPlogoninfo.AssetID As ID,
Count(tblCPlogoninfo.ID) As Count
From tblCPlogoninfo
Group By tblCPlogoninfo.Username,
tblCPlogoninfo.Domain,
tblCPlogoninfo.AssetID) SubQuery3 On SubQuery3.Username = SubQuery2.Username
And SubQuery3.Userdomain = SubQuery2.Userdomain And SubQuery3.Count =
SubQuery2.LogonCount
Inner Join tblAssets On tblAssets.AssetID = SubQuery3.ID
Inner Join tblADusers On tblADusers.Username = SubQuery2.Username And
tblADusers.Userdomain = SubQuery2.Userdomain
Order By SubQuery2.Userdomain,
SubQuery2.Username
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now