‎07-23-2021 05:21 PM
‎07-23-2021 05:55 PM
tblCPlogoninfo
This table stores the user logon events that occurred on your Windows computers.
Select Distinct Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Username,
tblAssets.Lastseen As [LastSeen Ordinateur]
From
tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where
tblAssets.AssetType = -1
And tblAssets.AssetName Like 'z%'
Select Distinct Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Username,
tblAssets.Lastseen As [LastSeen Ordinateur]
From
tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.AssetType
Where
tsysAssetTypes.AssetTypename = 'Windows'
And tblAssets.AssetName Like 'z%'
‎07-23-2021 07:05 PM
RC62N wrote:
First, from the query you presented, without the JOIN to tblCPlogoninfo you're listing all of your assets: Windows computers, printers, monitors, switches, etc. According to the database documentation:tblCPlogoninfo
This table stores the user logon events that occurred on your Windows computers.
When you INNER JOIN to tblCPlogoninfo, you're eliminating all assets that aren't Windows computers. That's one of the characteristics of an INNER join.
Additionally, if there are any Windows computers without anything recorded in tblCPlogoninfo, those assets will also be eliminated from the result set.
If all you want is a list of Windows computers, drop the JOIN to tblCPlogoninfo and add a filter to your WHERE clause:Select Distinct Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Username,
tblAssets.Lastseen As [LastSeen Ordinateur]
From
tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where
tblAssets.AssetType = -1
And tblAssets.AssetName Like 'z%'
If you'd prefer to filter the asset type by name than by code, link in the descriptions:Select Distinct Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Username,
tblAssets.Lastseen As [LastSeen Ordinateur]
From
tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.AssetType
Where
tsysAssetTypes.AssetTypename = 'Windows'
And tblAssets.AssetName Like 'z%'
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now