‎05-06-2021 09:17 PM
Select Top 1000000 tblassets.AssetID,
tblassets.AssetName,
tblassets.Username,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblassets.IPAddress,
tblassets.Lastseen,
tblSoftwareUni.softwareName As Software,
tblSoftware.softwareVersion As Version,
tblSoftwareUni.SoftwarePublisher As Publisher,
tsysIPLocations.IPLocation,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname As OS,
tblassets.Lasttried,
tblSoftware.Lastchanged
From tblassets
Inner Join tblAssetCustom On tblassets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblassets.Assettype
Inner Join tsysIPLocations On tsysIPLocations.LocationID =
tblassets.LocationID
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tblSoftware On tblassets.AssetID = tblSoftware.AssetID
Inner Join tblSoftwareUni On tblSoftwareUni.SoftID = tblSoftware.softID
Left Join tsysOS On tsysOS.OScode = tblassets.OScode
Where tblSoftwareUni.softwareName Like '7-ZIP%' And
tblSoftware.softwareVersion Not Like '19.00%' And tblState.Statename =
'Active'
Order By Version,
tblassets.Lastseen Desc,
tblassets.AssetName
Solved! Go to Solution.
‎06-16-2021 03:26 PM
I went and tried adding Installdate and Lastchanged from tblSoftware but that didn't seem give me correct values. Then I tried tblSoftwareHist Installdate and Lastchanged which may have given correct values. (I don't know the difference between the two tables.)
Select Top 1000000
tblassets.AssetID,
tblassets.AssetName,
tblassets.Username,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblassets.IPAddress,
tblassets.Lastseen,
tblSoftwareUni.softwareName As Software,
tblSoftware.softwareVersion As Version,
tblSoftwareUni.SoftwarePublisher As Publisher,
tblSoftware.InstallDate,
tblSoftware.LastChanged,
( SELECT -- if InstallDate is null, use LastChanged as a better-than-nothing alternative
Max(IsNull(tblSoftwareHist.InstallDate, tblSoftwareHist.LastChanged))
FROM
tblSoftwareHist
WHERE
tblSoftwareHist.AssetID = tblAssets.AssetID -- for this computer
AND tblSoftwareHist.SoftID = tblSoftware.SoftID -- and this piece of software
AND tblSoftwareHist.Action = 1 -- installed
-- prior to the current install
AND IsNull(tblSoftwareHist.InstallDate, tblSoftwareHist.LastChanged) < IsNull(tblSoftware.InstallDate, tblSoftware.LastChanged)
) AS PreviousInstall,
tsysIPLocations.IPLocation,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname As OS,
tblassets.Lasttried,
tblSoftware.Lastchanged
From
tblassets
Inner Join tblAssetCustom On tblassets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblassets.Assettype
Inner Join tsysIPLocations On tsysIPLocations.LocationID = tblassets.LocationID
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tblSoftware On tblassets.AssetID = tblSoftware.AssetID
Inner Join tblSoftwareUni On tblSoftwareUni.SoftID = tblSoftware.softID
Left Join tsysOS On tsysOS.OScode = tblassets.OScode
Where
tblSoftwareUni.softwareName Like '7-Zip%'
And tblSoftware.softwareVersion Not Like '19.00%'
And tblState.Statename = 'Active'
Order By
Version,
tblassets.Lastseen Desc,
tblassets.AssetName
‎06-16-2021 04:11 PM
‎06-16-2021 03:26 PM
I went and tried adding Installdate and Lastchanged from tblSoftware but that didn't seem give me correct values. Then I tried tblSoftwareHist Installdate and Lastchanged which may have given correct values. (I don't know the difference between the two tables.)
Select Top 1000000
tblassets.AssetID,
tblassets.AssetName,
tblassets.Username,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblassets.IPAddress,
tblassets.Lastseen,
tblSoftwareUni.softwareName As Software,
tblSoftware.softwareVersion As Version,
tblSoftwareUni.SoftwarePublisher As Publisher,
tblSoftware.InstallDate,
tblSoftware.LastChanged,
( SELECT -- if InstallDate is null, use LastChanged as a better-than-nothing alternative
Max(IsNull(tblSoftwareHist.InstallDate, tblSoftwareHist.LastChanged))
FROM
tblSoftwareHist
WHERE
tblSoftwareHist.AssetID = tblAssets.AssetID -- for this computer
AND tblSoftwareHist.SoftID = tblSoftware.SoftID -- and this piece of software
AND tblSoftwareHist.Action = 1 -- installed
-- prior to the current install
AND IsNull(tblSoftwareHist.InstallDate, tblSoftwareHist.LastChanged) < IsNull(tblSoftware.InstallDate, tblSoftware.LastChanged)
) AS PreviousInstall,
tsysIPLocations.IPLocation,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname As OS,
tblassets.Lasttried,
tblSoftware.Lastchanged
From
tblassets
Inner Join tblAssetCustom On tblassets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblassets.Assettype
Inner Join tsysIPLocations On tsysIPLocations.LocationID = tblassets.LocationID
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tblSoftware On tblassets.AssetID = tblSoftware.AssetID
Inner Join tblSoftwareUni On tblSoftwareUni.SoftID = tblSoftware.softID
Left Join tsysOS On tsysOS.OScode = tblassets.OScode
Where
tblSoftwareUni.softwareName Like '7-Zip%'
And tblSoftware.softwareVersion Not Like '19.00%'
And tblState.Statename = 'Active'
Order By
Version,
tblassets.Lastseen Desc,
tblassets.AssetName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now