SELECT
[conn2].[Name]
, [conn1].[TotalCount]
, [conn1].[LicenseInUseCount]
, [PercentageUsed] = (
CASE
WHEN [conn1].[LicenseInUseCount] > 0 THEN ROUND(((CAST ([conn1].[LicenseInUseCount] AS FLOAT) / 100.0) / (CAST( [conn1].[TotalCount] AS FLOAT ) / 100.0)) * 100, 2)
ELSE 0
END
)
, [LicenseType] = (
CASE [conn1].[IsTrial]
WHEN 0 THEN 'Full'
ELSE 'Trial'
END
)
, [conn1].[PolicyType]
, [conn1].[Status]
, [conn1].[CreatedDate]
, [conn1].[ModifiedDate]
, [conn1].[ExpireDate]
, [conn1].[AupDate]
FROM
[LicenseStatus] [conn1]
LEFT JOIN [Item] [conn2] ON [conn1].[LicensingPolicyGuid] = [conn2].[Guid]
WHERE
[conn1].[TotalCount] > 0
AND [conn2].[Name] IS NOT NULL
--AND ROUND(((CAST([conn1].[LicenseInUseCount] AS FLOAT) / 100.0) / (CAST([conn1].[TotalCount] AS FLOAT) / 100.0)) * 100, 2) > 90
ORDER BY
[conn2].[Name]