→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎10-31-2013 05:18 PM
Solved! Go to Solution.
‎11-04-2013 09:15 PM
Select Top 1000000 Case
When tblAssetCustom.Model Like 'Latitude E6420%' Then
'Standard Laptop (Latitude E64xx)'
When tblAssetCustom.Model Like 'Latitude E6430%' Then
'Standard Laptop (Latitude E64xx)'
When tblAssetCustom.Model Like 'Latitude E6520%' Then
'Eng Laptop (Latitude E65xx)'
When tblAssetCustom.Model Like 'Latitude E6530%' Then
'Eng Laptop (Latitude E65xx)'
When tblAssetCustom.Model Like 'Optiplex 790%' Then
'Standard Desktop (Optiplex 7xxx)'
When tblAssetCustom.Model Like 'Optiplex 7010%' Then
'Standard Desktop (Optiplex 7xxx)'
When tblAssetCustom.Model Like 'Precision Workstation T3500%' Then
'Eng Desktop (Precision T3xxx)'
When tblAssetCustom.Model Like 'Precision Workstation T3600%' Then
'Eng Desktop (Precision T3xxx)' End As AssetClass,
Sum(Case When tblState.State = 9 Then 1 Else 0 End) As Stock,
Sum(Case When tblState.State = 7 Then 1 Else 0 End) As Spare
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tblAssetGroupLink On tblAssets.AssetID = tblAssetGroupLink.AssetID
Inner Join tblAssetGroups On tblAssetGroups.AssetGroupID =
tblAssetGroupLink.AssetGroupID
Where tblAssets.Assettype = -1 And tblAssetGroups.AssetGroup = 'DLS' And
((tblAssetCustom.Model Like 'Latitude E6420%' And tblAssetGroups.AssetGroup =
'DLS') Or (tblAssetCustom.Model Like 'Latitude E6430%' And
tblAssetGroups.AssetGroup = 'DLS') Or (tblAssetCustom.Model Like
'Latitude E6520%' And tblAssetGroups.AssetGroup = 'DLS') Or
(tblAssetCustom.Model Like 'Latitude E6530%' And tblAssetGroups.AssetGroup =
'DLS') Or (tblAssetCustom.Model Like 'Optiplex 790%' And
tblAssetGroups.AssetGroup = 'DLS') Or (tblAssetCustom.Model Like
'Optiplex 7010%' And tblAssetGroups.AssetGroup = 'DLS') Or
(tblAssetCustom.Model Like 'Precision Workstation T3500%' And
tblAssetGroups.AssetGroup = 'DLS') Or (tblAssetCustom.Model Like
'Precision Workstation T3600%' And tblAssetGroups.AssetGroup = 'DLS'))
Group By Case
When tblAssetCustom.Model Like 'Latitude E6420%' Then
'Standard Laptop (Latitude E64xx)'
When tblAssetCustom.Model Like 'Latitude E6430%' Then
'Standard Laptop (Latitude E64xx)'
When tblAssetCustom.Model Like 'Latitude E6520%' Then
'Eng Laptop (Latitude E65xx)'
When tblAssetCustom.Model Like 'Latitude E6530%' Then
'Eng Laptop (Latitude E65xx)'
When tblAssetCustom.Model Like 'Optiplex 790%' Then
'Standard Desktop (Optiplex 7xxx)'
When tblAssetCustom.Model Like 'Optiplex 7010%' Then
'Standard Desktop (Optiplex 7xxx)'
When tblAssetCustom.Model Like 'Precision Workstation T3500%' Then
'Eng Desktop (Precision T3xxx)'
When tblAssetCustom.Model Like 'Precision Workstation T3600%' Then
'Eng Desktop (Precision T3xxx)' End,
tsysAssetTypes.AssetTypename
‎11-01-2013 03:45 PM
Select Top 1000000 Coalesce(tblAssetCustom.Manufacturer, N'Unknown') As Vendor,
Coalesce(tblAssetCustom.Model, N'Unknown') As AssetModel,
Sum(Case When tblState.State = 9 Then 1 Else 0 End) As Stock,
Sum(Case When tblState.State = 2 Then 1 Else 0 End) As [Non-Active]
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblState On tblState.State = tblAssetCustom.State
Where tblAssets.Assettype = -1
Group By Coalesce(tblAssetCustom.Manufacturer, N'Unknown'),
Coalesce(tblAssetCustom.Model, N'Unknown'),
tsysAssetTypes.AssetTypename
‎10-31-2013 10:12 PM
CASE
WHEN tblstate.State IN (1, 9)
THEN 1
ELSE 0
END
CASE
WHEN (tblstate.State = 1)
OR (tblstate.State = 9)
THEN 1
ELSE 0
END
‎10-31-2013 08:37 PM
Sum(CASE WHEN tblstate.State = 1 THEN 1 ELSE 0 END) AS Active,to
Sum(CASE WHEN tblstate.State = 9 THEN 1 ELSE 0 END) AS Stock,, so now how to I adjust the totals column to reflect the sum of only these 2 columns?
‎10-31-2013 06:46 PM
SELECT Top 1000000
tsysAssetTypes.AssetTypename,
Coalesce(tblAssetCustom.Manufacturer, N'Unknown') AS Vendor,
Coalesce(tblAssetCustom.Model, N'Unknown') AS AssetModel,
Sum(CASE WHEN tblstate.State = 1 THEN 1 ELSE 0 END) AS Active,
Sum(CASE WHEN tblstate.State = 2 THEN 1 ELSE 0 END) AS [Non-Active],
Sum(CASE WHEN tblstate.State <= 2 THEN 1 ELSE 0 END) AS Total
FROM
tblAssets
INNER JOIN tblAssetCustom ON tblAssets.AssetID = tblAssetCustom.AssetID
INNER JOIN tsysAssetTypes ON tsysAssetTypes.AssetType = tblAssets.Assettype
INNER JOIN tblstate ON tblstate.State = tblAssetCustom.State
WHERE
tblAssets.Assettype = -1
GROUP BY
tsysAssetTypes.AssetTypename,
Coalesce(tblAssetCustom.Manufacturer, N'Unknown'),
Coalesce(tblAssetCustom.Model, N'Unknown')
‎10-31-2013 06:34 PM
SELECT Top 1000000
tsysAssetTypes.AssetTypename,
Coalesce(tblAssetCustom.Manufacturer, N'Unknown') AS Vendor,
Coalesce(tblAssetCustom.Model, N'Unknown') AS AssetModel,
tblstate.State,
tblstate.Statename,
Count(tblAssets.AssetID) AS Total
FROM
tblAssets
INNER JOIN tblAssetCustom ON tblAssets.AssetID = tblAssetCustom.AssetID
INNER JOIN tsysAssetTypes ON tsysAssetTypes.AssetType = tblAssets.Assettype
INNER JOIN tblstate ON tblstate.State = tblAssetCustom.State
WHERE
tblAssets.Assettype = -1
GROUP BY
tsysAssetTypes.AssetTypename,
Coalesce(tblAssetCustom.Manufacturer, N'Unknown'),
Coalesce(tblAssetCustom.Model, N'Unknown'),
tblstate.State,
tblstate.Statename
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now