→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎02-19-2018 02:00 PM
Select Top 1000000 tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.AssetName,
tblAssets.AssetID,
tblAssets.Username,
tsysIPLocations.IPLocation,
tblADusers.Firstname,
tblADusers.Lastname,
tblADusers.email,
tblADusers.Department,
tblADusers.EmployeeID,
tblOperatingsystem.Caption,
tblAssets.Firstseen,
tblBIOS.Manufacturer,
tblAssetCustom.Model,
tblBIOS.SerialNumber,
tblstate.Statename,
tblADComputers.OU,
tblOperatingsystem.InstallDate,
tblCPlogoninfo.logontime,
tblCPlogoninfo.Username As Username1
From tblAssets
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Outer Join tsysIPLocations On tblAssets.IPNumeric >=
tsysIPLocations.StartIP And tblAssets.IPNumeric <= tsysIPLocations.EndIP
Left Join tblADusers On tblADusers.Username = tblAssets.Username And
tblADusers.Userdomain = tblAssets.Userdomain
Inner Join tblOperatingsystem
On tblAssets.AssetID = tblOperatingsystem.AssetID
Inner Join tblBIOS On tblAssets.AssetID = tblBIOS.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblstate On tblstate.State = tblAssetCustom.State
Inner Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Inner Join tblCPlogoninfo On tblAssets.AssetID = tblCPlogoninfo.AssetID
Where tblstate.Statename = 'active' And tblComputersystem.Domainrole < 2
Order By tsysIPLocations.IPLocation
Solved! Go to Solution.
‎02-23-2018 01:31 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
subquery1.Username,
subquery1.Domain,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.IPAddress,
subquery1.logontime,
tblAssets.Lastseen,
tblAssets.Lasttried
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Join (Select Row_Number() Over (Partition By tblCPlogoninfo.AssetID Order
By tblCPlogoninfo.AssetID) As RowNumber,
tblCPlogoninfo.AssetID,
tblCPlogoninfo.logontime,
tblCPlogoninfo.Domain,
tblCPlogoninfo.Username
From tblCPlogoninfo) As subquery1 On subquery1.AssetID = tblAssets.AssetID
Where subquery1.RowNumber < 4 And tblAssetCustom.State = 1
Order By tblAssets.AssetName,
subquery1.logontime Desc
‎02-23-2018 01:31 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
subquery1.Username,
subquery1.Domain,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.IPAddress,
subquery1.logontime,
tblAssets.Lastseen,
tblAssets.Lasttried
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Join (Select Row_Number() Over (Partition By tblCPlogoninfo.AssetID Order
By tblCPlogoninfo.AssetID) As RowNumber,
tblCPlogoninfo.AssetID,
tblCPlogoninfo.logontime,
tblCPlogoninfo.Domain,
tblCPlogoninfo.Username
From tblCPlogoninfo) As subquery1 On subquery1.AssetID = tblAssets.AssetID
Where subquery1.RowNumber < 4 And tblAssetCustom.State = 1
Order By tblAssets.AssetName,
subquery1.logontime Desc
‎02-20-2018 10:10 AM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now