‎12-12-2019 05:40 PM
Solved! Go to Solution.
‎12-16-2019 11:23 AM
SELECT DISTINCT Top 1000000
COALESCE(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) AS icon,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
CASE
WHEN (sha2patch.AssetID IS NOT NULL) AND (SSUMarApr.AssetID IS NOT NULL) AND (SSUSep.AssetID IS NOT NULL) AND (MonthlyRollups.AssetID IS NOT NULL)
THEN 'Up to date'
ELSE 'Out of date'
END AS [Patch status],
CASE
WHEN tblComputersystem.Domainrole > 1
THEN 'Server'
ELSE 'Workstation'
END AS [Workstation/Server],
tblAssets.Username,
tblAssets.IPAddress,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname AS OS,
tblAssets.SP,
tblAssets.Lasttried,
CASE
WHEN sha2patch.AssetID IS NULL then 'SHA-2 code signing support update missing'
WHEN SSUMarApr.AssetID IS NULL then 'Servicing stack update from March(W7/W2008R2) or April(W2008) missing'
WHEN SSUSep.AssetID IS NULL then 'Servicing stack update from September missing'
WHEN MonthlyRollups.AssetID IS NULL then 'Monthly rollup patch missing'
ELSE ''
END AS [Missing Patches],
CONVERT(nvarchar,DATEDIFF(DAY, QuickFixLastScanned.QuickFixLastScanned, GETDATE())) + ' days ago' AS WindowsUpdateInfoLastScanned,
CASE
WHEN (sha2patch.AssetID IS NOT NULL) AND (SSUMarApr.AssetID IS NOT NULL) AND (SSUSep.AssetID IS NOT NULL) AND (MonthlyRollups.AssetID IS NOT NULL)
THEN '#d4f4be'
ELSE '#ffadad'
END AS backgroundcolor
FROM
tblAssets
INNER JOIN tblAssetCustom ON tblAssets.AssetID = tblAssetCustom.AssetID
INNER JOIN tsysAssetTypes ON tsysAssetTypes.AssetType = tblAssets.Assettype
INNER JOIN tblOperatingsystem ON tblOperatingsystem.AssetID = tblAssets.AssetID
INNER JOIN tblState ON tblState.State = tblAssetCustom.State
INNER JOIN tblComputersystem ON tblAssets.AssetID = tblComputersystem.AssetID
LEFT JOIN tsysOS ON tsysOS.OScode = tblAssets.OScode
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID = 'KB4474419') AS sha2patch ON sha2patch.AssetID = tblAssets.AssetID
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID in ('KB4493730','KB4490628')) AS SSUMarApr ON SSUMarApr.AssetID = tblAssets.AssetID
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID in ('KB4516655','KB4517134')) AS SSUSep ON SSUSep.AssetID = tblAssets.AssetID
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID IN ('KB4519976', 'KB4519972', 'KB4525235', 'KB4525251', 'KB4530734','KB4520002', 'KB4520015', 'KB4525234', 'KB4525244', 'KB4530695')) AS MonthlyRollups ON MonthlyRollups.AssetID = tblAssets.AssetID
LEFT JOIN tsysIPLocations ON tblAssets.IPNumeric >= tsysIPLocations.StartIP AND tblAssets.IPNumeric <= tsysIPLocations.EndIP
LEFT JOIN (SELECT DISTINCT
TsysLastscan.AssetID AS ID,
TsysLastscan.Lasttime AS QuickFixLastScanned
FROM
TsysWaittime
INNER JOIN TsysLastscan ON TsysWaittime.CFGCode = TsysLastscan.CFGcode
WHERE
TsysWaittime.CFGname = 'QUICKFIX'
) AS QuickFixLastScanned ON tblAssets.AssetID = QuickFixLastScanned.ID
LEFT JOIN (SELECT DISTINCT
tblErrors.AssetID AS ID,
MAX(tblErrors.Teller) AS ErrorID
FROM
tblErrors
GROUP BY
tblErrors.AssetID
) AS ScanningError ON tblAssets.AssetID = ScanningError.ID
LEFT JOIN tblErrors ON ScanningError.ErrorID = tblErrors.Teller
LEFT JOIN tsysasseterrortypes ON tsysasseterrortypes.Errortype = tblErrors.ErrorType
WHERE
(tsysOS.OSname LIKE 'Win 7%' OR tsysOS.OSname LIKE 'Win 2008 R2' Or tsysOS.OSname LIKE 'Win 2008')
AND tblAssetCustom.State = 1
AND tsysAssetTypes.AssetTypename LIKE 'Windows%'
ORDER BY
tblAssets.AssetName
‎12-17-2019 01:13 PM
‎12-16-2019 04:46 PM
‎12-16-2019 04:37 PM
WHERE
tsysOS.OSname LIKE 'Win 7%'
OR tsysOS.OSname LIKE 'Win 2008 R2'
Or (tsysOS.OSname LIKE 'Win 2008'
AND tblAssetCustom.State = 1
AND tsysAssetTypes.AssetTypename LIKE 'Windows%')
WHERE
(tsysOS.OSname LIKE 'Win 7%' OR tsysOS.OSname LIKE 'Win 2008 R2' Or tsysOS.OSname LIKE 'Win 2008')
AND tblAssetCustom.State = 1
AND tsysAssetTypes.AssetTypename LIKE 'Windows%'
‎12-16-2019 11:23 AM
SELECT DISTINCT Top 1000000
COALESCE(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) AS icon,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
CASE
WHEN (sha2patch.AssetID IS NOT NULL) AND (SSUMarApr.AssetID IS NOT NULL) AND (SSUSep.AssetID IS NOT NULL) AND (MonthlyRollups.AssetID IS NOT NULL)
THEN 'Up to date'
ELSE 'Out of date'
END AS [Patch status],
CASE
WHEN tblComputersystem.Domainrole > 1
THEN 'Server'
ELSE 'Workstation'
END AS [Workstation/Server],
tblAssets.Username,
tblAssets.IPAddress,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname AS OS,
tblAssets.SP,
tblAssets.Lasttried,
CASE
WHEN sha2patch.AssetID IS NULL then 'SHA-2 code signing support update missing'
WHEN SSUMarApr.AssetID IS NULL then 'Servicing stack update from March(W7/W2008R2) or April(W2008) missing'
WHEN SSUSep.AssetID IS NULL then 'Servicing stack update from September missing'
WHEN MonthlyRollups.AssetID IS NULL then 'Monthly rollup patch missing'
ELSE ''
END AS [Missing Patches],
CONVERT(nvarchar,DATEDIFF(DAY, QuickFixLastScanned.QuickFixLastScanned, GETDATE())) + ' days ago' AS WindowsUpdateInfoLastScanned,
CASE
WHEN (sha2patch.AssetID IS NOT NULL) AND (SSUMarApr.AssetID IS NOT NULL) AND (SSUSep.AssetID IS NOT NULL) AND (MonthlyRollups.AssetID IS NOT NULL)
THEN '#d4f4be'
ELSE '#ffadad'
END AS backgroundcolor
FROM
tblAssets
INNER JOIN tblAssetCustom ON tblAssets.AssetID = tblAssetCustom.AssetID
INNER JOIN tsysAssetTypes ON tsysAssetTypes.AssetType = tblAssets.Assettype
INNER JOIN tblOperatingsystem ON tblOperatingsystem.AssetID = tblAssets.AssetID
INNER JOIN tblState ON tblState.State = tblAssetCustom.State
INNER JOIN tblComputersystem ON tblAssets.AssetID = tblComputersystem.AssetID
LEFT JOIN tsysOS ON tsysOS.OScode = tblAssets.OScode
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID = 'KB4474419') AS sha2patch ON sha2patch.AssetID = tblAssets.AssetID
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID in ('KB4493730','KB4490628')) AS SSUMarApr ON SSUMarApr.AssetID = tblAssets.AssetID
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID in ('KB4516655','KB4517134')) AS SSUSep ON SSUSep.AssetID = tblAssets.AssetID
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID IN ('KB4519976', 'KB4519972', 'KB4525235', 'KB4525251', 'KB4530734','KB4520002', 'KB4520015', 'KB4525234', 'KB4525244', 'KB4530695')) AS MonthlyRollups ON MonthlyRollups.AssetID = tblAssets.AssetID
LEFT JOIN tsysIPLocations ON tblAssets.IPNumeric >= tsysIPLocations.StartIP AND tblAssets.IPNumeric <= tsysIPLocations.EndIP
LEFT JOIN (SELECT DISTINCT
TsysLastscan.AssetID AS ID,
TsysLastscan.Lasttime AS QuickFixLastScanned
FROM
TsysWaittime
INNER JOIN TsysLastscan ON TsysWaittime.CFGCode = TsysLastscan.CFGcode
WHERE
TsysWaittime.CFGname = 'QUICKFIX'
) AS QuickFixLastScanned ON tblAssets.AssetID = QuickFixLastScanned.ID
LEFT JOIN (SELECT DISTINCT
tblErrors.AssetID AS ID,
MAX(tblErrors.Teller) AS ErrorID
FROM
tblErrors
GROUP BY
tblErrors.AssetID
) AS ScanningError ON tblAssets.AssetID = ScanningError.ID
LEFT JOIN tblErrors ON ScanningError.ErrorID = tblErrors.Teller
LEFT JOIN tsysasseterrortypes ON tsysasseterrortypes.Errortype = tblErrors.ErrorType
WHERE
(tsysOS.OSname LIKE 'Win 7%' OR tsysOS.OSname LIKE 'Win 2008 R2' Or tsysOS.OSname LIKE 'Win 2008')
AND tblAssetCustom.State = 1
AND tsysAssetTypes.AssetTypename LIKE 'Windows%'
ORDER BY
tblAssets.AssetName
‎12-13-2019 06:46 PM
SELECT DISTINCT Top 1000000
COALESCE(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) AS icon,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
CASE
WHEN (sha2patch.AssetID IS NOT NULL) AND (SSUMar.AssetID IS NOT NULL) AND (SSUSep.AssetID IS NOT NULL) AND (MonthlyRollups.AssetID IS NOT NULL)
THEN 'Up to date'
ELSE 'Out of date'
END AS [Patch status],
CASE
WHEN tblComputersystem.Domainrole > 1
THEN 'Server'
ELSE 'Workstation'
END AS [Workstation/Server],
tblAssets.Username,
tblAssets.IPAddress,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname AS OS,
tblAssets.SP,
tblAssets.Lasttried,
CASE
WHEN (sha2patch.AssetID IS NOT NULL) AND (SSUMar.AssetID IS NOT NULL) AND (SSUSep.AssetID IS NOT NULL) AND (MonthlyRollups.AssetID IS NOT NULL)
THEN ''
ELSE 'Still needs ESU Patches'
END AS [Install ESU Patches],
CONVERT(nvarchar,DATEDIFF(DAY, QuickFixLastScanned.QuickFixLastScanned, GETDATE())) + ' days ago' AS WindowsUpdateInfoLastScanned,
CASE
WHEN (sha2patch.AssetID IS NOT NULL) AND (SSUMar.AssetID IS NOT NULL) AND (SSUSep.AssetID IS NOT NULL) AND (MonthlyRollups.AssetID IS NOT NULL)
THEN '#d4f4be'
ELSE '#ffadad'
END AS backgroundcolor
FROM
tblAssets
INNER JOIN tblAssetCustom ON tblAssets.AssetID = tblAssetCustom.AssetID
INNER JOIN tsysAssetTypes ON tsysAssetTypes.AssetType = tblAssets.Assettype
INNER JOIN tblOperatingsystem ON tblOperatingsystem.AssetID = tblAssets.AssetID
INNER JOIN tblState ON tblState.State = tblAssetCustom.State
INNER JOIN tblComputersystem ON tblAssets.AssetID = tblComputersystem.AssetID
LEFT JOIN tsysOS ON tsysOS.OScode = tblAssets.OScode
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID = 'KB4474419') AS sha2patch ON sha2patch.AssetID = tblAssets.AssetID
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID = 'KB4490628') AS SSUMar ON SSUMar.AssetID = tblAssets.AssetID
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID = 'KB4516655') AS SSUSep ON SSUSep.AssetID = tblAssets.AssetID
LEFT JOIN (Select
tblQuickFixEngineering.AssetID
From
tblQuickFixEngineering
Left Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
Where
tblQuickFixEngineeringUni.HotFixID IN ('KB4519976', 'KB4519972', 'KB4525235', 'KB4525251', 'KB4530734')) AS MonthlyRollups ON MonthlyRollups.AssetID = tblAssets.AssetID
LEFT JOIN tsysIPLocations ON tblAssets.IPNumeric >= tsysIPLocations.StartIP AND tblAssets.IPNumeric <= tsysIPLocations.EndIP
LEFT JOIN (SELECT DISTINCT
TsysLastscan.AssetID AS ID,
TsysLastscan.Lasttime AS QuickFixLastScanned
FROM
TsysWaittime
INNER JOIN TsysLastscan ON TsysWaittime.CFGCode = TsysLastscan.CFGcode
WHERE
TsysWaittime.CFGname = 'QUICKFIX'
) AS QuickFixLastScanned ON tblAssets.AssetID = QuickFixLastScanned.ID
LEFT JOIN (SELECT DISTINCT
tblErrors.AssetID AS ID,
MAX(tblErrors.Teller) AS ErrorID
FROM
tblErrors
GROUP BY
tblErrors.AssetID
) AS ScanningError ON tblAssets.AssetID = ScanningError.ID
LEFT JOIN tblErrors ON ScanningError.ErrorID = tblErrors.Teller
LEFT JOIN tsysasseterrortypes ON tsysasseterrortypes.Errortype = tblErrors.ErrorType
WHERE
tsysOS.OSname LIKE 'Win 7%'
AND tblAssetCustom.State = 1
AND tsysAssetTypes.AssetTypename LIKE 'Windows%'
ORDER BY
tblAssets.AssetName
‎12-13-2019 04:52 PM
‎12-13-2019 03:14 PM
‎12-13-2019 10:11 AM
INNER JOIN tblQuickFixEngineeringUni AS MonthlyRollup ON MonthlyRollup.QFEID = tblQuickFixEngineering.QFEID AND MonthlyRollup.HotFixID IN ('KB4519976', 'KB4519972', 'KB4525235', 'KB4525251', 'KB4530734')
INNER JOIN tblQuickFixEngineeringUni AS MonthlyRollup ON MonthlyRollup.QFEID = tblQuickFixEngineering.QFEID AND MonthlyRollup.HotFixID = 'KB4530734'
‎12-12-2019 06:43 PM
SELECT TOP 1000000
tblQuickFixEngineering.AssetID
FROM
tblQuickFixEngineering
INNER JOIN tblQuickFixEngineeringUni ON tblQuickFixEngineeringUni.QFEID = tblQuickFixEngineering.QFEID
WHERE
tblQuickFixEngineeringUni.HotFixID IN ('KB4519976',
'KB4519972',
'KB4525235',
'KB4525251',
'KB4530734')
AND tblQuickFixEngineeringUni.HotFixID = 'KB4490628'
AND tblQuickFixEngineeringUni.HotFixID = 'KB4474419'
AND tblQuickFixEngineeringUni.HotFixID = 'KB4516655'
Show me results when:
x is any one of (1, 2, 3, 4, 5)
AND x = 6
AND x = 7
AND x = 8
SELECT TOP 1000000
tblQuickFixEngineering.AssetID
FROM
tblQuickFixEngineering
INNER JOIN tblQuickFixEngineeringUni AS sha2patch ON sha2patch.QFEID = tblQuickFixEngineering.QFEID AND sha2patch.HotFixID = 'KB4474419'
INNER JOIN tblQuickFixEngineeringUni AS SSUMar ON SSUMar.QFEID = tblQuickFixEngineering.QFEID AND SSUMar.HotFixID = 'KB4490626'
INNER JOIN tblQuickFixEngineeringUni AS SSUSep ON SSUSep.QFEID = tblQuickFixEngineering.QFEID AND SSUSep.HotFixID = 'KB4516655'
INNER JOIN tblQuickFixEngineeringUni AS MonthlyRollup ON MonthlyRollup.QFEID = tblQuickFixEngineering.QFEID AND MonthlyRollup.HotFixID IN ('KB4519976', 'KB4519972', 'KB4525235', 'KB4525251', 'KB4530734')
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now