→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎09-10-2015 09:35 AM
Solved! Go to Solution.
‎09-12-2015 03:27 PM
Select Top 1000000 SubQuery2.Username,
SubQuery2.Userdomain,
tblADusers.Name,
SubQuery2.ComputersLoggedInto,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tblAssetCustom.Serialnumber,
tblAssets.IPAddress,
tsysIPLocations.IPLocation,
tblAssetCustom.Custom6 As AssignedLocation,
tblAssetCustom.Custom7 As SubLocation,
tblAssetCustom.Custom4 As FPRunit,
Max(tblCPlogoninfo.logontime) As MaxLogon
From (Select Top 1000000 SubQuery1.Username,
SubQuery1.Domain As Userdomain,
Count(SubQuery1.AssetID) As ComputersLoggedInto
From (Select Distinct Top 1000000 tblCPlogoninfo.Username,
tblCPlogoninfo.Domain,
tblCPlogoninfo.AssetID
From tblCPlogoninfo
Inner Join tblAssetCustom On tblAssetCustom.AssetID =
tblCPlogoninfo.AssetID
Where tblAssetCustom.State = 1) SubQuery1
Group By SubQuery1.Username,
SubQuery1.Domain) SubQuery2
Left Join tblADusers On tblADusers.Username = SubQuery2.Username And
tblADusers.Userdomain = SubQuery2.Userdomain
Inner Join tblCPlogoninfo On tblCPlogoninfo.Username = SubQuery2.Username And
tblCPlogoninfo.Domain = SubQuery2.Userdomain
Inner Join tblAssets On tblAssets.AssetID = tblCPlogoninfo.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Left Join tsysIPLocations On tsysIPLocations.StartIP <= tblAssets.IPNumeric
And tsysIPLocations.EndIP >= tblAssets.IPNumeric
Where tblAssetCustom.State = 1 And SubQuery2.ComputersLoggedInto > 1
Group By SubQuery2.Username,
SubQuery2.Userdomain,
tblADusers.Name,
SubQuery2.ComputersLoggedInto,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tblAssetCustom.Serialnumber,
tblAssets.IPAddress,
tsysIPLocations.IPLocation,
tblAssetCustom.Custom6,
tblAssetCustom.Custom7,
tblAssetCustom.Custom4
Order By SubQuery2.Userdomain,
SubQuery2.Username
‎09-12-2015 03:27 PM
Select Top 1000000 SubQuery2.Username,
SubQuery2.Userdomain,
tblADusers.Name,
SubQuery2.ComputersLoggedInto,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tblAssetCustom.Serialnumber,
tblAssets.IPAddress,
tsysIPLocations.IPLocation,
tblAssetCustom.Custom6 As AssignedLocation,
tblAssetCustom.Custom7 As SubLocation,
tblAssetCustom.Custom4 As FPRunit,
Max(tblCPlogoninfo.logontime) As MaxLogon
From (Select Top 1000000 SubQuery1.Username,
SubQuery1.Domain As Userdomain,
Count(SubQuery1.AssetID) As ComputersLoggedInto
From (Select Distinct Top 1000000 tblCPlogoninfo.Username,
tblCPlogoninfo.Domain,
tblCPlogoninfo.AssetID
From tblCPlogoninfo
Inner Join tblAssetCustom On tblAssetCustom.AssetID =
tblCPlogoninfo.AssetID
Where tblAssetCustom.State = 1) SubQuery1
Group By SubQuery1.Username,
SubQuery1.Domain) SubQuery2
Left Join tblADusers On tblADusers.Username = SubQuery2.Username And
tblADusers.Userdomain = SubQuery2.Userdomain
Inner Join tblCPlogoninfo On tblCPlogoninfo.Username = SubQuery2.Username And
tblCPlogoninfo.Domain = SubQuery2.Userdomain
Inner Join tblAssets On tblAssets.AssetID = tblCPlogoninfo.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Left Join tsysIPLocations On tsysIPLocations.StartIP <= tblAssets.IPNumeric
And tsysIPLocations.EndIP >= tblAssets.IPNumeric
Where tblAssetCustom.State = 1 And SubQuery2.ComputersLoggedInto > 1
Group By SubQuery2.Username,
SubQuery2.Userdomain,
tblADusers.Name,
SubQuery2.ComputersLoggedInto,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tblAssetCustom.Serialnumber,
tblAssets.IPAddress,
tsysIPLocations.IPLocation,
tblAssetCustom.Custom6,
tblAssetCustom.Custom7,
tblAssetCustom.Custom4
Order By SubQuery2.Userdomain,
SubQuery2.Username
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now