04-02-2018 04:47 PM
06-19-2018 10:07 AM
Select Top 1000000 tblLicenses.softwareName As [Software Name],
InUseCount.InUseLicenses As [In Use],
LicenseCount.PurchasedLicenses As Purchased,
(InUseCount.InUseLicenses - LicenseCount.PurchasedLicenses) As Shortfall,
InUseCount.LicenseidID,
tblLicenses.LicenseidID As LicenseidID1
From tblLicenses
Left Join tsyslicensetype On tsyslicensetype.LicenseType =
tblLicenses.LicenseType
Left Join (Select tblSublicensesOrders.LicenseidID,
Sum(tblSublicensesOrders.Nrlicenses) As PurchasedLicenses
From tblSublicensesOrders
Group By tblSublicensesOrders.LicenseidID) As LicenseCount
On LicenseCount.LicenseidID = tblLicenses.LicenseidID
Left Join (Select tblSublicenses.LicenseidID,
Count(*) As InUseLicenses
From tblSublicenses
Inner Join (Select tblSoftwareUni.softwareName,
tblSoftware.softwareVersion
From tblSoftware
Inner Join tblSoftwareUni On tblSoftwareUni.SoftID = tblSoftware.softID
Inner Join tblAssetCustom On tblAssetCustom.AssetID = tblSoftware.AssetID
Where tblAssetCustom.State = 1) As Software On Software.softwareName =
tblSublicenses.softwareName And Software.softwareVersion =
tblSublicenses.softwareVersion
Group By tblSublicenses.LicenseidID) As InUseCount On InUseCount.LicenseidID =
tblLicenses.LicenseidID
Order By [Software Name]
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now