‎04-17-2019 06:19 PM
Solved! Go to Solution.
‎04-17-2019 06:58 PM
‎04-17-2019 07:39 PM
‎04-17-2019 07:21 PM
‎04-17-2019 06:58 PM
‎04-17-2019 08:32 PM
endyk wrote:
The last changed date in tblDiskdrives is causing the duplicate. You will want to get the max lastchange date details for each asset from the table. Below is an updated query that will work.
Select Top 1000000 tsysOS.Image As icon,
tblAssetCustom.AssetID,
tblAssets.AssetName,
tblAssetCustom.PurchaseDate As [Purchase Date],
tblAssetCustom.Warrantydate As [Warranty Expiration],
tblAssets.Domain,
tblAssets.Username,
tblAssets.IPAddress,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname As OS,
tblAssets.Lastseen,
tblAssets.Memory,
tblAssets.Processor,
Cast(tblDiskdrives.Freespace / 1024 / 1024 / 1024 As numeric) As FreeGB,
Cast(tblDiskdrives.Size / 1024 / 1024 / 1024 As numeric) As TotalSizeGB,
Ceiling(tblDiskdrives.Freespace / (Case tblDiskdrives.Size
When 0 Then 1
Else tblDiskdrives.Size
End) * 100) As [%SpaceLeft],
tblDiskdrives.Lastchanged
From tblAssetCustom
Inner Join tblAssets On tblAssetCustom.AssetID = tblAssets.AssetID
Inner Join tsysOS On tblAssets.OScode = tsysOS.OScode
Inner Join (select dd.*
from tblDiskdrives dd
inner join (select distinct AssetID,max(Lastchanged) as Lastchanged from tblDiskdrives group by AssetID) lc on lc.AssetID = dd.AssetID and lc.Lastchanged = dd.Lastchanged) tblDiskdrives on tblAssets.AssetID = tblDiskdrives.AssetID
Where (tblAssetCustom.PurchaseDate Is Not Null And tblAssetCustom.State = 1) Or
(tblAssetCustom.Warrantydate Is Not Null And tblAssetCustom.State = 1)
Order By tblAssets.AssetName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now