‎02-12-2016 10:13 PM
Select Cast(tblSublicensesOrders.Comments As NVARCHAR(100)) DEPT,
tblLicenses.softwareName,
Sum(tblSublicensesOrders.Nrlicenses) As PurchasedLicenses
From tblSublicensesOrders
Inner Join tblLicenses On tblLicenses.LicenseidID =
tblSublicensesOrders.LicenseidID
Group By Cast(tblSublicensesOrders.Comments As NVARCHAR(100)),
tblLicenses.softwareName
Select Top 1000000 tblADusers.Department,
tblLicenses.softwareName,
count(*) As InUseCount
From tblLicenses
Left Join tblSoftwareUni On tblSoftwareUni.softwareName =
tblLicenses.softwareName
Inner Join tblSoftware On tblSoftwareUni.SoftID = tblSoftware.softID
Inner Join tblAssets On tblAssets.AssetID = tblSoftware.AssetID
Inner Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
Inner Join tblADusers On tblAssets.Username = tblADusers.Username
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where (tblAssetCustom.State = 1 Or tblAssetCustom.State = 2) And
(tblADComputers.OU Like '%Rockwall%' Or tblADComputers.OU Like '%Shared%' Or
tblADComputers.OU Like '%EMS%') And tblADusers.Userdomain = 'Greenville'
Group By tblADusers.Department,
tblLicenses.softwareName
Solved! Go to Solution.
‎05-02-2017 04:25 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.IPAddress,
tblAssets.Domain,
tblAssets.Username,
tblAssets.Memory,
tblAssets.Processor,
tblAssetCustom.PurchaseDate,
tblAssetCustom.Warrantydate,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAntivirus.DisplayName As AntiVirus,
tblAntivirus.productUpToDate,
tblOperatingsystem.Caption As OperatingSystem,
tblOperatingsystem.Organization,
Sum(Cast(Cast(tblDiskdrives.Size As BigInt) / 1024 / 1024 / 1024 As Numeric))
As [Total size (GB)],
Sum(Cast(Cast(tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric)) As [Free in GB]
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Join tblAntivirus On tblAssets.AssetID = tblAntivirus.AssetID
Inner Join tblOperatingsystem
On tblAssets.AssetID = tblOperatingsystem.AssetID
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Where tblAssets.Domain Like '%lekpas%' And tblAssetCustom.State = 1 And
tblDiskdrives.DriveType = 3
Group By tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10,
tblAssets.IPAddress,
tblAssets.Domain,
tblAssets.Username,
tblAssets.Memory,
tblAssets.Processor,
tblAssetCustom.PurchaseDate,
tblAssetCustom.Warrantydate,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAntivirus.DisplayName,
tblAntivirus.productUpToDate,
tblOperatingsystem.Caption,
tblOperatingsystem.Organization
Order By tblAssets.Domain,
tblAssets.AssetName
‎05-02-2017 04:25 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.IPAddress,
tblAssets.Domain,
tblAssets.Username,
tblAssets.Memory,
tblAssets.Processor,
tblAssetCustom.PurchaseDate,
tblAssetCustom.Warrantydate,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAntivirus.DisplayName As AntiVirus,
tblAntivirus.productUpToDate,
tblOperatingsystem.Caption As OperatingSystem,
tblOperatingsystem.Organization,
Sum(Cast(Cast(tblDiskdrives.Size As BigInt) / 1024 / 1024 / 1024 As Numeric))
As [Total size (GB)],
Sum(Cast(Cast(tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric)) As [Free in GB]
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Join tblAntivirus On tblAssets.AssetID = tblAntivirus.AssetID
Inner Join tblOperatingsystem
On tblAssets.AssetID = tblOperatingsystem.AssetID
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Where tblAssets.Domain Like '%lekpas%' And tblAssetCustom.State = 1 And
tblDiskdrives.DriveType = 3
Group By tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10,
tblAssets.IPAddress,
tblAssets.Domain,
tblAssets.Username,
tblAssets.Memory,
tblAssets.Processor,
tblAssetCustom.PurchaseDate,
tblAssetCustom.Warrantydate,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAntivirus.DisplayName,
tblAntivirus.productUpToDate,
tblOperatingsystem.Caption,
tblOperatingsystem.Organization
Order By tblAssets.Domain,
tblAssets.AssetName
‎04-26-2017 02:20 PM
‎02-21-2016 05:00 PM
Select Top 1000000 SubQuery1.Department,
SubQuery1.softwareName,
SubQuery1.InUseCount,
SubQuery2.PurchasedLicenses
From (Select Top 1000000 tblADusers.Department,
tblLicenses.softwareName,
count(*) As InUseCount
From tblLicenses
Left Join tblSoftwareUni On tblSoftwareUni.softwareName =
tblLicenses.softwareName
Inner Join tblSoftware On tblSoftwareUni.SoftID = tblSoftware.softID
Inner Join tblAssets On tblAssets.AssetID = tblSoftware.AssetID
Left Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
Left Join tblADusers On tblAssets.Username = tblADusers.Username And
tblADusers.Userdomain = tblAssets.Userdomain
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where (tblAssetCustom.State = 1 Or tblAssetCustom.State = 2) And
(tblADComputers.OU Like '%rockwall%' Or tblADComputers.OU Like '%shared%' Or
tblADComputers.OU Like '%ems%') And tblADusers.Userdomain = 'greenville'
Group By tblADusers.Department,
tblLicenses.softwareName) SubQuery1
Left Join (Select Cast(tblSublicensesOrders.Comments As NVARCHAR(100)) DEPT,
tblLicenses.softwareName,
Sum(tblSublicensesOrders.Nrlicenses) As PurchasedLicenses
From tblSublicensesOrders
Inner Join tblLicenses On tblLicenses.LicenseidID =
tblSublicensesOrders.LicenseidID
Group By Cast(tblSublicensesOrders.Comments As NVARCHAR(100)),
tblLicenses.softwareName) SubQuery2 On SubQuery2.DEPT = SubQuery1.Department
And SubQuery2.softwareName = SubQuery1.softwareName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now