I would like to create a report which displays the amount of laptop user was logged on as the last user. For example there will be plenty of machines where the Administrator account was used as the last logged on user. I would like to display it in 3 columns - Username, Amount, AssetName(hostname of a laptop). Only the users who were logged-on on more that 1 laptop should be displayed.

The end result should look similar to this one:

Below is what I've already accomplished to create but unfortunately I can't get CTE to work in the right way.

Quote:

With LaptopsPerUser (UsernameL, Total) As (Select Top 1000000 tblAssets.Username, Count(tblAssets.Username) As totalFrom tblAssets Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype Inner Join tblUsers On tblAssets.AssetID = tblUsers.AssetIDWhere tblAssets.AssetName Like '%-lt-%' And tblAssets.AssetName Like '%-lt-%' And tsysAssetTypes.AssetTypename Like '%windows%'Group By tblAssets.Username),OtherData (AssetName) As (Select Top 1000000 tblAssets.AssetName, tblAssets.UsernameFrom tblAssetsWhere tblAssets.AssetName Like '%-lt-%' And tblAssets.AssetName Like '%-lt-%' And tsysAssetTypes.AssetTypename Like '%windows%')Select * from LaptopsPerUserUnionSelect * from OtherData