‎05-11-2018 11:13 PM
Select Distinct Top 1000000 tsysOS.Image As Icon,
tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Domain,
tblAssets.IPAddress,
tblAssets.Memory,
Cast(CorrectMemory.Used As numeric) As [Slots used],
tblPhysicalMemoryArray.MemoryDevices - CorrectMemory.Used As [Slots free],
tblPhysicalMemoryArray.MemoryDevices As [Slots available],
tblProcessor.Name As [Processor Series],
tblDiskdrives.Caption As Drive,
Cast(Cast(dbo.tblDiskdrives.Size As BigInt) / 1024 / 1024 / 1024 As Numeric)
As [Total size (GB)],
Cast(Cast(dbo.tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric) As [Free in GB],
Cast((Cast(dbo.tblDiskdrives.Size As BigInt) -
Cast(dbo.tblDiskdrives.Freespace As BigInt)) / 1024 / 1024 / 1024 As
Numeric) As [Used Space (GB)],
Cast(Cast(Cast(dbo.tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric) / Cast(Cast(dbo.tblDiskdrives.Size As BigInt) / 1024 / 1024 /
1024 As Numeric) * 100 As bigint) As [% Free],
tblAssets.Firstseen,
tblAssets.Lastseen
From tblAssets
Inner Join tblPhysicalMemoryArray On tblAssets.AssetID =
tblPhysicalMemoryArray.AssetID
Inner Join (Select tblAssets.AssetID,
Sum(Ceiling(tblPhysicalMemory.Capacity / 1024 / 1024)) As Memory,
Count(tblPhysicalMemory.Win32_PhysicalMemoryid) As Used
From tblAssets
Left Outer Join (TsysMemorytypes
Right Outer Join tblPhysicalMemory On TsysMemorytypes.Memorytype =
tblPhysicalMemory.MemoryType) On tblAssets.AssetID =
tblPhysicalMemory.AssetID
Group By tblAssets.AssetID,
tblPhysicalMemory.MemoryType
Having tblPhysicalMemory.MemoryType <> 11) CorrectMemory
On CorrectMemory.AssetID = tblAssets.AssetID
Inner Join tsysOS On tblAssets.OScode = tsysOS.OScode
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblPhysicalMemory On tblAssets.AssetID = tblPhysicalMemory.AssetID
Inner Join TsysMemorytypes On TsysMemorytypes.Memorytype =
tblPhysicalMemory.MemoryType
Inner Join tblProcessor On tblAssets.AssetID = tblProcessor.AssetID
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Where tsysOS.OSname Not Like 'Win 2%' And tblDiskdrives.Caption = 'C:'
And tblPhysicalMemoryArray.[Use] = 3 And tblAssetCustom.State = 1
Order By tblAssets.Domain,
tblAssets.AssetName
Solved! Go to Solution.
‎05-14-2018 10:45 PM
CASE
WHEN condition1 THEN red
WHEN condition2 THEN yellow
WHEN condition3 THEN red
WHEN condition4 THEN cyan
WHEN condition5 THEN green
WHEN condition6 OR condition7 OR condition8 THEN magenta
WHEN condition9 THEN blue
ELSE black
END AS foregroundcolor
‎05-15-2018 04:41 PM
‎05-15-2018 03:37 PM
‎05-14-2018 10:56 PM
CASE
WHEN free_space < 10% THEN red
WHEN warranty_expired THEN red
ELSE black
END AS foregroundcolor
‎05-14-2018 10:45 PM
CASE
WHEN condition1 THEN red
WHEN condition2 THEN yellow
WHEN condition3 THEN red
WHEN condition4 THEN cyan
WHEN condition5 THEN green
WHEN condition6 OR condition7 OR condition8 THEN magenta
WHEN condition9 THEN blue
ELSE black
END AS foregroundcolor
‎05-14-2018 05:37 PM
‎05-14-2018 08:39 PM
RC62N wrote:
Refer to this thread. You should be able to use the information there to set up a CASE statement to assign the colours you want.
Select Distinct Top 1000000 tsysOS.Image As Icon,
tblAssets.AssetID,
tblAssets.AssetName As [WorkStation Name],
tsysOS.OSname As OS,
tblAssetCustom.Model,
tblAssets.Domain,
tblAssets.IPAddress,
tsysIPLocations.IPLocation As Site,
tblAssets.Memory,
Cast(CorrectMemory.Used As numeric) As [Slots used],
tblPhysicalMemoryArray.MemoryDevices - CorrectMemory.Used As [Slots free],
tblPhysicalMemoryArray.MemoryDevices As [Slots available],
Case When tblProcessor.Name Not Like 'Intel Core i%' Then '#fbfb86'
End As backgroundcolor,
tblProcessor.Name As [Processor Series],
tblDiskdrives.Caption As Drive,
Cast(Cast(dbo.tblDiskdrives.Size As BigInt) / 1024 / 1024 / 1024 As Numeric)
As [Total size (GB)],
Cast(Cast(dbo.tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric) As [Free Space (GB)],
Cast((Cast(dbo.tblDiskdrives.Size As BigInt) -
Cast(dbo.tblDiskdrives.Freespace As BigInt)) / 1024 / 1024 / 1024 As
Numeric) As [Used Space (GB)],
Case
When Cast(Cast(Cast(dbo.tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric) / Cast(Cast(dbo.tblDiskdrives.Size As BigInt) / 1024 /
1024 / 1024 As Numeric) * 100 As bigint) <= 10 Then 'red'
End As foregroundcolor,
Cast(Cast(Cast(dbo.tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric) / Cast(Cast(dbo.tblDiskdrives.Size As BigInt) / 1024 / 1024 /
1024 As Numeric) * 100 As bigint) As [% Free],
tblAssets.Firstseen,
tblAssets.Lastseen,
tblAssetCustom.PurchaseDate,
Convert(Varchar(10),tblAssetCustom.Warrantydate,101) As [Warranty Expiration]
From tblAssets
Inner Join tblPhysicalMemoryArray On tblAssets.AssetID =
tblPhysicalMemoryArray.AssetID
Inner Join (Select tblAssets.AssetID,
Sum(Ceiling(tblPhysicalMemory.Capacity / 1024 / 1024)) As Memory,
Count(tblPhysicalMemory.Win32_PhysicalMemoryid) As Used
From tblAssets
Left Outer Join (TsysMemorytypes
Right Outer Join tblPhysicalMemory On TsysMemorytypes.Memorytype =
tblPhysicalMemory.MemoryType) On tblAssets.AssetID =
tblPhysicalMemory.AssetID
Group By tblAssets.AssetID,
tblPhysicalMemory.MemoryType
Having tblPhysicalMemory.MemoryType <> 11) CorrectMemory
On CorrectMemory.AssetID = tblAssets.AssetID
Inner Join tsysOS On tblAssets.OScode = tsysOS.OScode
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblPhysicalMemory On tblAssets.AssetID = tblPhysicalMemory.AssetID
Inner Join TsysMemorytypes On TsysMemorytypes.Memorytype =
tblPhysicalMemory.MemoryType
Inner Join tblProcessor On tblAssets.AssetID = tblProcessor.AssetID
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Inner Join tsysIPLocations On tsysIPLocations.LocationID =
tblAssets.LocationID
Where (tblAssets.AssetName Not Like 'BLAHblah-%' And
tsysOS.OSname Not Like 'Win 2%' And tblAssets.Domain = 'BLAH' And
tblDiskdrives.Caption = 'C:' And tblPhysicalMemoryArray.[Use] = 3 And
tblAssetCustom.State = 1) Or
(tsysOS.OSname Not Like 'Win 2%' And tblAssets.Domain = 'BLAHBLAH' And
tblDiskdrives.Caption = 'C:' And tblPhysicalMemoryArray.[Use] = 3 And
tblAssetCustom.State = 1)
Order By Site,
[WorkStation Name]
Convert(Varchar(10),tblAssetCustom.Warrantydate,101) As [Warranty Expiration]
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now