cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
TimH
Engaged Sweeper III
I have seen a few other examples of how to add the last logon time to a report but I cannot get any of them to work.

Here is my query so far:

Select Distinct Top 1000000 tblAssets.AssetName,
tblAssets.Username,
tblOperatingsystem.Caption As [OS Version],
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.Lastseen,
tblAssetCustom.Manufacturer,
tblAssets.AssetID,
tblAssetCustom.Model
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Inner Join tblOperatingsystem
On tblAssets.AssetID = tblOperatingsystem.AssetID
Where tblAssetCustom.Manufacturer Like '%vmware%' And
tblComputersystem.Domainrole < 2 And tblAssetCustom.State = 1
Order By tblAssets.AssetName

I just want to add a column to the report that shows the last logon time of the user (tblAssets.Username).

Any help is appreciated.

Thanks!
1 REPLY 1
TimH
Engaged Sweeper III
Figured it out:

Select Distinct Top 1000000 tblAssets.AssetName,
tblAssets.Lastseen,
tblAssets.Username,
Max(tblCPlogoninfo.logontime) As [Last Logon],
tblOperatingsystem.Caption As [OS Version],
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssetCustom.Manufacturer,
tblAssets.AssetID,
tblAssetCustom.Model
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Inner Join tblOperatingsystem
On tblAssets.AssetID = tblOperatingsystem.AssetID
Inner Join tblCPlogoninfo On tblAssets.Username = tblCPlogoninfo.Username And
tblAssets.Userdomain = tblCPlogoninfo.Domain
Where tblAssetCustom.Manufacturer Like '%vmware%' And
tblComputersystem.Domainrole < 2 And tblAssetCustom.State = 1
Group By tblAssets.AssetName,
tblAssets.Lastseen,
tblAssets.Username,
tblOperatingsystem.Caption,
tsysAssetTypes.AssetTypeIcon10,
tblAssetCustom.Manufacturer,
tblAssets.AssetID,
tblAssetCustom.Model
Order By tblAssets.AssetName