‎11-20-2014 01:04 PM
SELECT
tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename As AssetType,
tsysAssetTypes.AssetTypeIcon10,
tblAssets.IPAddress,
tsysIPlocations.IPLocation,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAssets.Lastseen,
tblAssets.Lasttried,
Cast(tblCustDevPrinter.TonerRemaining As nvarchar) + '%' as RemainingPercentage,
tblCustDevPrinter.TonerMaximum,
tblCustDevPrinter.Tonername,
tblCustDevPrinter.TonerColorName,
tblCustDevPrinter.Lastchanged
FROM tblCustDevPrinter
INNER JOIN tblAssets ON tblCustDevPrinter.AssetID = tblAssets.AssetID
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
Left Join tsysOS On tsysOS.OScode = tblAssets.OScode
WHERE
tblCustDevPrinter.TonerMaximum <> 0
AND tblCustDevPrinter.TonerRemaining <> 0
AND (FLOOR(tblCustDevPrinter.TonerRemaining / (CASE WHEN tblCustDevPrinter.TonerMaximum = 0 THEN 1 ELSE tblCustDevPrinter.TonerMaximum END) * 100) <= 10)
AND (FLOOR(tblCustDevPrinter.TonerRemaining / (CASE WHEN tblCustDevPrinter.TonerMaximum = 0 THEN 1 ELSE tblCustDevPrinter.TonerMaximum END) * 100) >= 0)
AND (tblCustDevPrinter.TonerMaximum > 0)
AND tblState.Statename = 'Active' And tsysAssetTypes.AssetTypename = 'Printer'
Order By RemainingPercentage, tblAssets.Domain, tblAssets.AssetName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now