Substitute for your
RemainingPercentage.
Select Top 1000000
tblAssets.AssetID,
tblAssets.AssetName As [Printer Name],
tblAssetCustom.Custom11 As [MT Asset Tag],
tblAssets.IPAddress As [IP Address],
tsysIPLocations.IPLocation As [Facility Location],
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
Convert( VarChar(10),
Cast( Case
When tblCustDevPrinter.TonerMaximum > 0
Then tblCustDevPrinter.TonerRemaining / tblCustDevPrinter.TonerMaximum * 100
End
As Decimal(6,2))) + '%' As RemainingPercentage,
...
The funny thing is, you've handled it in your WHERE clause. You could just as easily copy your code from there to use as the
RemainingPercentage value.
Select Top 1000000
tblAssets.AssetID,
tblAssets.AssetName As [Printer Name],
tblAssetCustom.Custom11 As [MT Asset Tag],
tblAssets.IPAddress As [IP Address],
tsysIPLocations.IPLocation As [Facility Location],
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
Cast(Floor(tblCustDevPrinter.TonerRemaining / (Case
When tblCustDevPrinter.TonerMaximum = 0
Then 1
Else tblCustDevPrinter.TonerMaximum
End) * 100) As nvarchar) + '%' As RemainingPercentage,
...